Page 1 of 1

[SOLVED] MACOSX - Linker issue (ld: library not found)

Posted: Mon May 15, 2017 3:19 pm
by Raymi
Hello,

I am newbie with CodeLite, but not sure it is a CodeLite problem as the problem also occurs with xcode when using the provided command. It looks like the compiler doesn't find the static lib (nLib_utils.a), however it well exists as it has been successfully compiled.

The error occurs when trying to build a console executable on MACOSX, the static lib header just contains standards:

Code: Select all

#include <iostream>
#include <string>
#include <clocale>
#include <ctime>
#include <unistd.h>
In the console executable, the header contains:

Code: Select all

#include "nLib_utils.h"
Command & output:

Code: Select all

/Applications/Xcode.app/Contents/Developer/usr/bin/g++ -o /Output/StandAlone_Bin/OSX/Debug/Test_UT /Output/StandAlone_Bin/OSX/Debug/main.cpp.o   -L. -L/Output/Libs/OSX/Debug  lnLib_utils
ld: library not found for -lnLib_utils
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [/Output/StandAlone_Bin/OSX/Debug/Test_UT] Error 1
Using -v to see invocation produces somehow the same result.

Many thanks in advance for any help

Re: MACOSX - Linker issue (ld: library not found)

Posted: Mon May 22, 2017 6:45 pm
by Raymi
For those who might be facing the same issue, just ensure your static library file name starts with "lib" and ends up with ".a".