-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add -fPIC flag #42
Add -fPIC flag #42
Conversation
Add -fPIC so that console_bridge can be linked statically with other libraries (i.e. `BUILD_SHARED_LIBS` is `OFF`)
@scpeters no worries! Here's a very concise explanation of what the cons of http://stackoverflow.com/a/4036497 I can make the logic a bit smarter, for example check if it's being built statically and only add the |
If we can bump the |
Trusty uses cmake 2.8.12, so @traversaro's suggestion seems viable to me: |
This seems to fail on Windows: http://ci.ros2.org/job/ci_windows/2451/ |
I don't see a major problem by adding the I don't know the reason of generating only a static library for console_bridge. Adding the generation of a shared library is also an easy approach.
I'm unable to locate exactly the error in the build log ... :( |
Search for "error " in the console output. |
I don't see the error either. There are 217 instances of Also, it's not obvious why that windows build failure is related to this PR, since the change is inside an |
I think what @dirk-thomas is pointing out here is that this fix doesn't solve the fact that |
I found the error. You can find the error quickly using a search for "2 Error" +1 for using the cmake property instead of the |
I see it now, thanks.
AFAIK, there is no Position Independent Code in Windows. It could be that the problem is related to how the visibility is handled in the code. I see that the code is using |
The |
Oh, I did not know about this one, thanks. I'm afraid that we are mixing the shared visibility with the generation of a static library. Looking at the diff --git a/CMakeLists.txt b/CMakeLists.txt
index d64bd17..f32b78d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,6 +39,10 @@ if(NOT DEFINED BUILD_SHARED_LIBS)
option(BUILD_SHARED_LIBS "Build dynamically-linked binaries" ON)
endif()
+if(NOT BUILD_SHARED_LIBS)
+ add_definitions("-DCONSOLE_BRIDGE_STATIC")
+endif()
+
# Control where libraries and executables are placed during the build
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}") |
Yes, the Windows compilation failure is not related at all to I had a bit of déjà vu discussing this, and then I remember that the same patch was proposed in this PR : #40 . I think this is not the ideal solution, as outlined in #40 (comment) . It is worth mentioning that a way to avoid dealing with this kind of issues directly is to export all the symbols present in a given library, using CMake's |
And here I was searching for "supercalifragilisticexpialidocious", no wonder I never find anything wrong in my log files 😜 @traversaro 's suggestion is much clearer than adding @mikaelarguedas as @j-rivero said, the error is not caused by the lack of For this specific case, @traversaro suggested on #40 (comment) a while ago several approaches on how to address this. |
Oops! I just saw @traversaro 's previous comment 😄 |
-1 , we can not scale it to other (bigger) libraries due to the mentioned performance reasons.
+1 |
I'm +1 on requiring cmake 2.8.9 since 2.8.12 is available in trusty |
I've implemented (hopefully right) the suggestion of using the export header macro in #43 |
Closing in favor of #43 Thanks @j-rivero ! @dirk-thomas triggered a CI build for Windows (http://ci.ros2.org/job/ci_windows/2474/) and it seems to have passed, yay! |
Add -fPIC so that console_bridge can be linked statically with other libraries (i.e.
BUILD_SHARED_LIBS
isOFF
)