Skip to content
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

clang: error: linker command failed with exit code 1 (use -v to see invocation) #2997

Closed
SJGong opened this issue Apr 13, 2019 · 17 comments
Closed

Comments

@SJGong
Copy link

SJGong commented Apr 13, 2019

  • Operating System and version: MacOS Mojave 10.14.4
  • Compiler: CLion2018
  • PCL Version: 1.9.1

When I want to complier the PCL project, there are kinds of errors, for example:
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [untitled] Error 1
make[2]: *** [CMakeFiles/untitled.dir/all] Error 2
make[1]: *** [CMakeFiles/untitled.dir/rule] Error 2
make: *** [untitled] Error 2
I have tried many ways except for reinstalling my system, but I failed, and there are no much similar situation. macOS 10.13 has not such problems.

I want to know if these problems are leaded by macOS10.14? Have any way to solve them? Thank you so much!

@SergioRAgostinho
Copy link
Member

I don't think we will be able to help you with just this information. The error log just tells us you have a linking error. I'm still on High Sierra but we had Mojave users reporting successful compilation before.

Is it just version 1.9.1 that you're not able to compile or also the current master branch?

@SJGong
Copy link
Author

SJGong commented Apr 13, 2019

I installed CMake and PCL through homebrew, I think that everything is up to date. I tried from December of last year and started from the newest PCL version, but there were always kinds of errors, including the cmake error about not finding glew.
Could you tell me about the installation process of the Mojave users who successful compilation, please?

@SergioRAgostinho
Copy link
Member

I installed CMake and PCL through homebrew, I think that everything is up to date.

So it means that you're not trying to compile PCL, but your own project which uses PCL. That wasn't clear. If that's the case and you're having linking problems can you post the CMakeLists.txt file for your project?

I tried from December of last year and started from the newest PCL version, but there were always kinds of errors, including the cmake error about not finding glew.
Could you tell me about the installation process of the Mojave users who successful compilation, please?

I can't help you with this. I've seen reports about that glew problem, but at this point migrating to Mojave is not an option for me and our CI infrastructure is still on High Sierra. However, it seems Mojave was deployed just last month to Azure Pipelines so we can upgrade it, see what happens and hopefully bump into whatever problem there might exist.

@SJGong
Copy link
Author

SJGong commented Apr 13, 2019

Your soonest response will be highly appreciated. Yes, I have not tried to compile PCL, just my own project uses PCL. I also think that you can have a try and to see what will happen after upgrade.

This is the CMakeLists.txt of my project:

cmake_minimum_required(VERSION 3.13)
project(T191_2)

find_package(PCL 1.9.1 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_DEFINITIONS})
add_definitions(${PCL_DEFINITIONS})

set(CMAKE_CXX_STANDARD 14)

add_executable(T191_2 main.cpp)
target_link_libraries(T191_2 ${PCL_LIBRARIES})

@SergioRAgostinho
Copy link
Member

Try removing the following lines

include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_DEFINITIONS})
add_definitions(${PCL_DEFINITIONS})

@SJGong
Copy link
Author

SJGong commented Apr 13, 2019

I tried, but still the error.

@SJGong
Copy link
Author

SJGong commented Apr 13, 2019

And I compiled PCL1.9.1 with CMake just, there`s no problems.

@arnoldn1
Copy link

Are you by chance getting the error ld: library not found for -lflann as well?

@SergioRAgostinho
Copy link
Member

Are you by chance getting the error ld: library not found for -lflann as well?

That particular bug should be fixed already, although it wan't released yet. Try to compile the current master and give it a try.

@SJGong
Copy link
Author

SJGong commented Apr 17, 2019

你偶然得到错误ld: library not found for -lflann吗?

Yes, sometimes. I have solved now, though it is not perfect. I install PCL1.8.1 first through homebrew, then new a project through CLion with C++ Standard 11. Then upgrade the PCL, succeed. But this way can not new a project again, because it will have the glew error in new projects.

@arnoldn1
Copy link

If you are trying to avoid compiling from master, I was able to get around that linking error using the homebrew install of PCL 1.9.1_3 by copying the current FindFLANN.cmake to /usr/local/Cellar/pcl/1.9.1_3/share/modules. You may be able to fix some errors of a similar nature through the same method.

@klintan
Copy link

klintan commented Jul 6, 2019

I installed Glew using Brew and had to add the default linked path for Brew to the FindGlew.cmake script.

Line 61 in the FindGLEW.cmake file add
/usr/local/include/
to be the first path. It will search the includes from brew.

Hopefully the code on the master-branch solves this since PCL is going to use the Cmake builtin FindGLEW.cmake script.

@taketwo
Copy link
Member

taketwo commented Jul 6, 2019

Could you try master branch? Is there any specific reason why you prefer an old version?

@klintan
Copy link

klintan commented Jul 6, 2019

Could you try master branch? Is there any specific reason why you prefer an old version?

I installed it via Brew and I'm using it as a dependency in a ROS2 module, so that was the reason for not building it myself etc. Pure lazyness, but I'll try it out and report back :)

@MakGulati
Copy link

FindGLEW.cmake

i didnt understand this part
could you please elaborate it a bit.
Thanks in advance.

@klintan
Copy link

klintan commented Sep 28, 2019

Run
brew info pcl

and then for your version/install dir open the findGLEW.cmake file in Sublime for instance

sublime /usr/local/Cellar/pcl/1.9.1_4/share/pcl-1.9/Modules/FindGLEW.cmake

then line 61 in that file:

    FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h
      /usr/include/GL
      /usr/openwin/share/include
      /usr/openwin/include
      /usr/X11R6/include
      /usr/include/X11
      /opt/graphics/OpenGL/include
      /opt/graphics/OpenGL/contrib/libglew
    )

inside the parentheses here add
/usr/local/include/

However this should probably not be necessary in the latest version, not even sure why I had to do it.

@kunaltyagi
Copy link
Member

Closing due to inactivity (And since MacOS has deprecated OpenGL, and thus glew by extension)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants