undefined symbols prevent linking on OSX / homebrew setup #97
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
KittenSquad/glewlwyd#97
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
As mentioned here I got this working by adding
LDFLAGS="-Wl,-undefined -Wl,dynamic_lookup"to my env. Here's a more complete report of the problem.I've attached a terminal session with only a few minor edits for clarity. Also attached two of CMake's logs.
cmake-shell-log.txt
CMakeError.log
CMakeOutput.log
I'll look around to check if the
LDFLAGSis the only way for you to build or if there are improvements to make to the cmake script.Thanks for the bug report!
Hello @etuttle ,
Can you try the last commit
github.com/babelouest/glewlwyd@92009b4190and see if you still have the same error? I'm not sure this will fix everything but at least the cmake script is more clean to continue to work on this problem.Here's what I get with
make VERBOSE=1.92009b4.txt
I made another change in the cmake script to order the projects build:
github.com/babelouest/glewlwyd@bdb1dc4735Can you retry it?
I tried
bdb1dc4. It still fails with undefined symbol errors :-/.I've attached two logs this time. So far in this issue, I've had
-DCMAKE_POLICY_DEFAULT_CMP0079=NEWin my $cmake_opts. The first log (bdb1dc4.txt) has-DCMAKE_POLICY_DEFAULT_CMP0079=NEW, the second (bdb1dc4-2.txt) does not. The result is pretty similar, but cmake chooses a different build order. (It fails to link something different)bdb1dc4.txt
bdb1dc4-2.txt
I looked it up to remind myself why I had added that cmake setting, and it has to do with the "linking targets from other directories" error you might remember from #94. Wish I had remembered this detail earlier.
CMP0079was introduced in cmake 3.13. I have 3.15.5 on my Mac, and Travis currently has 3.12.4. Aha! I installed cmake 3.15.5 in my travis simulator container and tried to build #94 on linux again. It failed initially with:Then adding the option makes the build succeed. So that's one solution that we know works, but it requires a cmake upgrade.
What is the full command line you're using to build with cmake?
@etuttle , any update?
Strange, somehow I missed the notifications for the last couple updates to this issue...
The full command line I used to call cmake can be seen in the first few lines of the .txt files I posted (https://github.com/babelouest/glewlwyd/issues/97#issuecomment-577991174). I tend to use a $cmake_opts shell variable, but you can see where I define that variable on the previous line in the .txt file. Did you need more than that?
It seems likely that to solve this problem in clean way may require a cmake upgrade, but we also have the LDFLAGS work-around I mentioned in the issue report above.
So if I update the documentation for OSX users to use CMake 3.15.5 and add the flag
LDFLAGS="-Wl,-undefined -Wl,dynamic_lookup", this will do the trick?There are two paths I'm aware of:
-DCMAKE_POLICY_DEFAULT_CMP0079=NEW. Keep going down this path of addingtarget_link_librariesoradd_dependenciesuntil we get a clean build. I suspect the changes will end up looking like my branch in PR #94. This is the "clean" option because all platforms are the same, and there will be a minimum of undefined symbols / dangling links.LDFLAGS="-Wl,-undefined -Wl,dynamic_lookup". This works with old cmake and the existing cmake code in Glewlwyd. But it is unsatisfying because clang will ignore missing symbols when linking, and there are more of them than there has to be on OSX, because cmake isn't building in the ideal order.Requiring cmake to version 3.13 for all platforms isn't possible because this version is too recent and not present in some of the supported Linux distributions:
And Glewlwyd builds and runs fine on those versions
But if we can restrict to 3.13 for OSX only I have no problem with that:
Also, I'm totally ok with fixing and cleaning the order of
target_link_librariesandadd_dependenciesbut I don't have any OSX device nor the expertise to do that on my own, any help would be much appreciated.Concerning the option
-DCMAKE_POLICY_DEFAULT_CMP0079=NEW, since it's specific for OSX build, I can mention it in the paragraphInstall for OSXbut not for all platforms.Got it, so we're aiming to fix this so OSX builds get the ideal build order. But retain backwards compatibility with older cmake. At the cost of if/else statement(s) in CMakeLists.txt.
Let me take a shot at that. It may end up looking like PR #94, except with if/else statements around some of the
target_link_librariescalls:... because the cross-directory
target_link_librariesare required for newer cmake (and osx) but cause older cmake to fail with the error you mention in https://github.com/babelouest/glewlwyd/pull/94#issuecomment-576075808.Hello @etuttle , I'm wondering if you still plan to complete the build for OSX?
Oh I forgot about this one... sorry. Also I have a feeling that the solution we came up with is going to work everywhere but at the cost of ugly code in
CMakeLists.txt, which we won't like either...I'll try to spend some time coming up with an even better solution, but of course I have other things keeping me busy. If anyone else tries to build with homebrew libs, they should find this ticket which has hints and links to different ways to do it.