Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » How to find the path for a Directory? - Windows (undefined reference to `_imp__PathAppendA@8')
How to find the path for a Directory? - Windows [message #43955] Thu, 27 November 2014 14:04 Go to next message
rfdiaz
Messages: 4
Registered: November 2014
Location: USA
Junior Member
Hi,
I'm new to U++ trying to find "paths" under Windows.
This is my test code:
#include "stdio.h"
#include <windows.h>
#include <iostream>
#include "Shlwapi.h"

using namespace std;
int main(int argc, const char *argv[])
{
	// String for path name.
	char buffer_1[MAX_PATH] = "name_1\\name_2";
	char *lpStr1;
	lpStr1 = buffer_1;

	// String of what is being added.
	char buffer_2[ ] = "name_3";
	char *lpStr2;
	lpStr2 = buffer_2;

	cout << "The original path string is    " << lpStr1 << endl;
	cout << "The part to append to end is   " << lpStr2 << endl;
	bool ret = PathAppend(lpStr1,lpStr2);
	cout << "The appended path string is    " << lpStr1 << endl;
	return 0;
}

It gives the following error:
PathTest.cpp
PathTest: 1 file(s) built in (0:00.96), 967 msecs / file, duration = 983 msecs, parallelization 0%
Linking...
C:/upp/out/uppsrc/PathTest/MINGW.Debug.Debug_Full.Main.Sse2\ PathTest.o: In function `main':
C:/upp/uppsrc/PathTest/PathTest.cpp:21: undefined reference to `_imp__PathAppendA@8'
collect2.exe: error: ld returned 1 exit status

Maybe this is something obvious yet I have not been able to get it...

Searching on the subject I found a post at StackOverflow which suggests that
"You need to add the shlwapi library for linking:
gcc -o test test.c -lshlwapi"


Thanks for any Path to the solution!!!
Rfdiaz

Re: How to find the path for a Directory? - Windows [message #43956 is a reply to message #43955] Fri, 28 November 2014 08:27 Go to previous messageGo to next message
andreincx is currently offline  andreincx
Messages: 15
Registered: March 2014
Promising Member
Hi,

You're right. You'll need shlwapi.
See http://ultimatepp.org/app$ide$GettingStarted$en-us.html (Search for "What is stored where ?") which explain how you add a lib.

Project->Package organizer..
In main area of window press right click. Select "New Libraries..". In "When" field add WIN32 and in next field add shlwapi

Andrei
Re: How to find the path for a Directory? - Windows [message #43957 is a reply to message #43955] Fri, 28 November 2014 08:37 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello rfdiaz

Welcome to forum.

If you work in U++ you just need AppendFileName() function to append two paths.

If you also wants to browse through a folder, you can use this example:

String path = AppendFileName(dir, "*.*")
FindFile ff(path);
while(ff) {
	String name = ff.GetName();
	String namePath = AppendFileName(dir, name);
	if (ff.IsFile())
		DoSomething(namePath);
	else if(ff.IsFolder())
		DoMore(path, name);
	ff.Next();
}

To create a new command line U++ project you have to open TheIDE, choose "New package" and choose this option:

index.php?t=getfile&id=4671&private=0
CONSOLE_APP_MAIN is the main() of your program.

  • Attachment: Captur.JPG
    (Size: 57.85KB, Downloaded 398 times)


Best regards
IƱaki

[Updated on: Fri, 28 November 2014 08:38]

Report message to a moderator

Re: How to find the path for a Directory? - Windows [message #43962 is a reply to message #43957] Sat, 29 November 2014 13:45 Go to previous message
rfdiaz
Messages: 4
Registered: November 2014
Location: USA
Junior Member
Thanks for your response.

rfdiaz
Previous Topic: add library
Next Topic: Multiple Layout files
Goto Forum:
  


Current Time: Thu Mar 28 18:10:01 CET 2024

Total time taken to generate the page: 0.01511 seconds