codelite circular reference problem when using static libraries
#517 ouverte le 16 juin 2016
Métriques du dépôt
- Stars
- (3 621 étoiles)
- Métriques de merge PR
- (Métriques PR en attente)
Description
Hi, I'm new to using premake5 and codelite, but have encountered an issue that took most of the day to figure out. When a StaticLib project includes a different StaticLib project defined elsewhere and is linked to a ConsoleApp project through project linking cyclic references are not resolved correctly because codelite adds the project reference as a link option. This is added to the end of link command, after all the other libraries (where it should have been in front). Here is an example:
workspace "MyWorkspace"
project "Project1"
kind "StaticLib"
libdirs { "/path/to/externalLib" }
links { "externalLib" }
project "Project2"
kind "ConsoleApp"
libdirs { "/path/to/externalLib" }
links { "Project1",
"externalLib" }
files { "example.cpp" }
In Project2 even though externalLib is included after Project1, Project1 has unresolved symbols. Here is an example linker command:
/usr/lib/gcc/x86_64-linux-gnu/4.9/collect2 [.. skipping plugin opts, other opts & lib dirs ..] /obj/example.cpp.o -lexternalLib /bin/libProject1.a [.. skipping system libs ..]
This does not affect gmake Makefile because it's library output is enclosed in --start-group and --end-group and Project1 is at the start of libs like so:
/usr/lib/gcc/x86_64-linux-gnu/4.9/collect2 [.. skipping plugin opts, other opts & lib dirs ..] /obj/example.cpp.o --start-group /bin/libProject1.a -lexternalLib --end-group [.. skipping system libs ..]
I don't know if this is a gotcha, or a bug with premake/codelite, but am reporting it here in case someone else comes across the same issue. In my opinion the solution would be for codelite to move all object file definitions before libraries. As it stands I have changed the Project1 name and am linking into Project2 from the product directory:
workspace "MyWorkspace"
--note the underscore in the name
project "Project_1"
targetname "Project1"
kind "StaticLib"
libdirs { "/path/to/externalLib" }
links { "externalLib" }
project "Project2"
kind "ConsoleApp"
--note the path to the Project1 product dir
libdirs { "/path/to/externalLib",
"/path/to/Project_1/bin" }
links { "Project1",
"externalLib" }
files { "example.cpp" }