I have a C++ program test.cpp and I want to link two .lib files to it(fhlib.lib and gc_lib.lib).I have the .lib files in the same folder as my .cpp program. I'm on Windows 7.
What I have tried so far is the following:
g++ -o main main.cpp -L/Users\Documents\Visual Studio 2015\Projects\My Project -lfhlib
But I get an
No such file or directory error.
I'm sure the path is correct because I copied it from Properties->Location. But I had do delete the "C:\", because it was not compiling.
EDIT: I found this http://www.mingw.org/wiki/Specify_the_libraries_for_the_linker_to_use.
So I tried using
"-I" instead of "-l"
But still doesn't work.I get:
undefined reference to 'fh_set'...
If you're compiling with g++ on windows, I guess you're using MinGW: MinGW relies on .a libraries. When using the "-l" option, the compiler is looking for a library file with the extension .a.
Libraries in the format .lib are compiled with visual studio: you can't use it as this. Compile your libraries with MinGW if you have the sources or consider migrating your project to visual studio.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With