Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi!

If I link my application it can't find libraries in H:\MinGW\lib\gcc\mingw32\4.5.2, only in H:\MinGW\lib. I get these messages:
ld: cannot find crtbegin.o
ld: cannot find -lstdc++
ld: cannot find -lgcc
ld: cannot find crtend.o

I would need a solution that works for others, because I need this for an article. How can I make it work without specify the full path with -L option?

Thanks in advance
Posted
Comments
Richard MacCutchan 13-Sep-11 16:40pm    
Show the full text of your linker command so we can see exactly what you are doing.
Also check that your -L options precede your -l options.
Dávid Kocsis 14-Sep-11 0:53am    
I haven't specified any path, because its in the MinGW directory, and I only know where it is in my computer, in other computers it probably in another directory

1 solution

There is only four ways to specify the location of libraries you want to link to:

1. Copy (or symbolic link) the library into your working directory.
2. Copy the library into the standard default library directory
3. Specify the directory path for the library using -L
4. Add the directory path to the LD_LIBRARY_PATH variable.

Option #3 (specifying the path using the -L) command is generally the preferred method of doing it.

Copying the library from it's standard place to somewhere else (1&2) is bad practice because you can end up with outdated libraries when new ones are created/installed into the original location.

Specifying additional search paths in an environmental variable is generally frowned upon because that data isn't captured in your makefile.

At least if you hardcode a path into your linker command, the data is right there in you makefile and it's easily seen what the linker is doing.

That way when someone tries to build the project on a different system and the linker step fails, they just have to look at the linker command and fix up the library paths.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900