Codelite 4.1 - Static Libraries

CodeLite installation/troubleshooting forum
ColinTaylor
CodeLite Expert
Posts: 152
Joined: Fri Jul 15, 2011 2:49 pm
Genuine User: Yes
IDE Question: C++
Contact:

Codelite 4.1 - Static Libraries

Post by ColinTaylor »

Windows XP

Codelite/Wxwidgets/MinGW installed from "codelite-4.1.5770-mingw4.6.1-wx2.9.4.exe"

Since upgrading to Codelite 4.1, I haven't been able to link a static library that depends on another static library. (This worked fine prior to the upgrade)

The issue appears to be that the linker isn't finding the dependant static library

I've tried several different ways of specifying the Library Path in the Settings such as

Code: Select all

$(WorkspacePath)/WxReusablesLib/Debug
../WxReusablesLib/Debug
D:/CodeLiteWorkspaces/ActiveProjects/WxReusablesLib/Debug
And all lead to the following build output

Code: Select all

----------Build Started--------
C:\WINDOWS\system32\cmd.exe /c ""mingw32-make.exe" -e  -j 2 -f "ActiveProjects_wsp.mk""
----------Building project:[ WxReusablesLib - Debug ]----------
mingw32-make.exe[1]: Entering directory `D:/CodeLiteWorkspaces/ActiveProjects/WxReusablesLib'
mingw32-make.exe[1]: Nothing to be done for `all'.
mingw32-make.exe[1]: Leaving directory `D:/CodeLiteWorkspaces/ActiveProjects/WxReusablesLib'
----------Building project:[ WxSudokuSolverLib - Debug ]----------
mingw32-make.exe[1]: Entering directory `D:/CodeLiteWorkspaces/ActiveProjects/WxSudokuSolverLib'
ar rcus ./Debug/libWxSudokuSolverLib.a @"D:\CodeLiteWorkspaces\ActiveProjects\WxSudokuSolverLib\WxSudokuSolverLib.txt" "libWxReusablesLib.a" 
ar: libWxReusablesLib.a: No such file or directory
mingw32-make.exe[1]: *** [Debug/libWxSudokuSolverLib.a] Error 1
mingw32-make.exe: *** [All] Error 2
WxSudokuSolverLib.mk:80: recipe for target `Debug/libWxSudokuSolverLib.a' failed
mingw32-make.exe[1]: Leaving directory `D:/CodeLiteWorkspaces/ActiveProjects/WxSudokuSolverLib'
ActiveProjects_wsp.mk:4: recipe for target `All' failed
----------Build Ended----------
0 errors, 0 warnings
Please can someone suggest how to fix this?

Thanks, Colin
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Codelite 4.1 - Static Libraries

Post by eranif »

Does it make sense to run 'ar' with another library?
Won't it just archive the file as it is into the second archive?

Why don't you just link your executable directly to both libraries (libWxSudokuSolverLib.a AND libWxReusablesLib.a)

and remove the "LIbraries" set for 'WxSudokuSolverLib' (AFAIK, it does not work anyways, you cant link 2 static libraries - but I can be wrong here)

Eran
Make sure you have read the HOW TO POST thread
ColinTaylor
CodeLite Expert
Posts: 152
Joined: Fri Jul 15, 2011 2:49 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Codelite 4.1 - Static Libraries

Post by ColinTaylor »

Eran, your questions are all good ones, and maybe I will end up re-architecting the affected programs, but the current approach has worked on all previous versions of codelite that I've used (2.10. 3, 3.5 and 4) and now it doesn't work, so I assumed it would continue to work on 4.1.

Are you saying that this is something that won't be fixed?

(The reason its the way it is, is because classes in libWxSudokuSolverLib.a make use of classes in libWxReusablesLib.a, so it seemed logical to proceed the way I did, even if there were some alternatives)

Colin
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Codelite 4.1 - Static Libraries

Post by eranif »

ColinTaylor wrote:(The reason its the way it is, is because classes in libWxSudokuSolverLib.a make use of classes in libWxReusablesLib.a, so it seemed logical to proceed the way I did, even if there were some alternatives)
Since libWxSudokuSolverLib.a - there is no link taking place, so you can create libWxSudokuSolverLib.a archive without adding libWxReusablesLib.a. It only matters when actual linking is taking place (this is done for executable and shared library only)

FYI: in codelite < 4.1 libraries were not included in the creation line of the archive

So this line in codelite 4.1:

Code: Select all

ar rcus ./Debug/libWxSudokuSolverLib.a @"D:\CodeLiteWorkspaces\ActiveProjects\WxSudokuSolverLib\WxSudokuSolverLib.txt" "libWxReusablesLib.a"
was actually the below line in 4.0:

Code: Select all

ar rcus ./Debug/libWxSudokuSolverLib.a @"D:\CodeLiteWorkspaces\ActiveProjects\WxSudokuSolverLib\WxSudokuSolverLib.txt"
So I am pretty sure you can safely remove the library from the "Linker" page of WxSudokuSolverLib project settings (Libraries field)
Eran
Make sure you have read the HOW TO POST thread
ColinTaylor
CodeLite Expert
Posts: 152
Joined: Fri Jul 15, 2011 2:49 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Codelite 4.1 - Static Libraries

Post by ColinTaylor »

Eran, thanks again. Your suggestion works fine. :)
User avatar
Jarod42
CodeLite Expert
Posts: 240
Joined: Wed Sep 30, 2009 5:54 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Re: Codelite 4.1 - Static Libraries

Post by Jarod42 »

Related topic : Static lib does not link statically with the libs it's using.

Adding .a into a library seems useless.
To merge 2 static libraries (lib1, lib2 into lib1), you have to extract files from lib2 and add them into lib1.

I think linker options is misleading when building static lib since Options and Library Paths are ignored,
and Libraries is a place to add additional 'object files' to archive.

The 2 ignored options may be greyed when the Project Type is 'Static Lib'.
Post Reply