I am new for a C-programming and want to use igraph library.
I installed it via homebrew.
brew install igraph
After it i copy first example from igraph c tutorial in my main.cpp and change include igraph to
#include "igraph/igraph.h"
And Clion was suggest igraph functions and types.
Trying to build this a have error messages:
/Applications/CLion.app/Contents/bin/cmake/bin/cmake --build
/Users/username/development/graph_clustring/cmake-build-debug --target
graph_clustring -- -j 4
[ 50%] Linking CXX executable graph_clustring
Undefined symbols for architecture x86_64:
"_igraph_destroy", referenced from:
_main in main.cpp.o
"_igraph_diameter", referenced from:
_main in main.cpp.o
"_igraph_erdos_renyi_game", referenced from:
_main in main.cpp.o
"_igraph_rng_default", referenced from:
_main in main.cpp.o
"_igraph_rng_seed", referenced from:
_main in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
make[3]: *** [graph_clustring] Error 1
make[2]: *** [CMakeFiles/graph_clustring.dir/all] Error 2
make[1]: *** [CMakeFiles/graph_clustring.dir/rule] Error 2
make: *** [graph_clustring] Error 2e
I think that I should fix my CMake file, and help CMake find lib isntalled via homebrew.
CMake file:
cmake_minimum_required(VERSION 3.8)
project(graph_clustring)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
add_executable(graph_clustring ${SOURCE_FILES})
I was able to solve the problem by adding target_link_libraries command to a CMake. It should look like this
make_minimum_required(VERSION 3.8)
enter code here
project(graph_clustring)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
add_executable(graph_clustring ${SOURCE_FILES})
target_link_libraries(graph_clustring, igraph.a)
Related
The path:
/usr/local/include
/usr/local/lib
Outputs such an error:
Undefined symbols for architecture x86_64:
"cv::String::deallocate()", referenced from:
cv::String::~String() in main.o
cv::String::operator=(cv::String const&) in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
How to fix this error?
I am new to c++ and I am using CLion on a Mac. I would like to use the boost 1.65.0 filesystem library. When I add the following import statement the console app doesn't compile.
#include <boost/filesystem.hpp>
I get the following error:
Undefined symbols for architecture x86_64:
"boost::system::system_category()", referenced from:
___cxx_global_var_init.2 in main.cpp.o
"boost::system::generic_category()", referenced from:
boost::system::error_category::std_category::equivalent(int, std::__1::error_condition const&) const in main.cpp.o
boost::system::error_category::std_category::equivalent(std::__1::error_code const&, int) const in main.cpp.o
___cxx_global_var_init in main.cpp.o
___cxx_global_var_init.1 in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [sandbox] Error 1
make[2]: *** [CMakeFiles/sandbox.dir/all] Error 2
make[1]: *** [CMakeFiles/sandbox.dir/rule] Error 2
make: *** [sandbox] Error 2
CMake file:
cmake_minimum_required(VERSION 3.8)
project(sandbox)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES src/main.cpp)
find_package(Boost)
if (Boost_FOUND)
include_directories(${Boost_INCLUDE_DIR})
endif()
add_executable(sandbox ${SOURCE_FILES})
target_link_libraries (sandbox ${Boost_LIBRARIES})
Other libraries such as the boost string library works fine. But I cant use the filesystem library. Any idea what I am doing wrong?
I am currently working on a project using netcdf-c library. I have installed it using Homebrew. I have written a small script to write a .NC file. I am using a Mac
When I compile it in CLion using make main the following gets outputted:
make main
cc main.c -o main
Undefined symbols for architecture x86_64:
"_nc_close", referenced from:
_main in main-f43ab9.o
"_nc_get_var_int", referenced from:
_main in main-f43ab9.o
"_nc_inq_varid", referenced from:
_main in main-f43ab9.o
"_nc_open", referenced from:
_main in main-f43ab9.o
"_nc_strerror", referenced from:
_main in main-f43ab9.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [main] Error 1
This is the content of my Cmakelists.txt:
cmake_minimum_required(VERSION 3.6)
project(hello)
INCLUDE_DIRECTORIES(/usr/local/include)
LINK_DIRECTORIES(/usr/local/lib)
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /usr/local/lib)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} cc -stdlib=lnetcdf -Wall -Werror main.c")
INCLUDE_DIRECTORIES(/usr/local/include)
LINK_DIRECTORIES(/usr/local/lib)
set(SOURCE_FILES main.c)
add_executable(hello ${SOURCE_FILES})
Despite this I am able to execute my code by using the terminal and typing:
cc -lnetcdf main.c
Could someone tell me where the problem is?
Thanks
I'm trying to compile a cmake project on my mac, but it depends on the SDL.
I have alreaday read "LibSDL, CMake and MacOSX Lion", however I couldn't solve this problem.
CMakeList.txt
cmake_minimum_required(VERSION 2.6.4 FATAL_ERROR)
# Give a name to the project.
project(movehead)
# This include enable you to use our CMake framework
find_package(qibuild)
find_package(SDL REQUIRED)
link_directories( /usr/local/lib )
link_libraries (
${SDL_LIBRARY}
SDLmain
)
# Create an executable named movehead,
# with the source file : movehead.cpp
qi_create_bin(movehead movehead.cpp)
# Tell CMake that movehead depends on ALCOMMON.
# This will set the libraries to link movehead with,
# the include paths, and so on
qi_use_lib(movehead ALCOMMON)
Commandline
sudo qibuild make -c naoqi-sdk movehead Active configuration: naoqi-sdk (Debug)
Building movehead in naoqi-sdk (Debug)
Scanning dependencies of target movehead
Linking CXX executable sdk/bin/movehead
ld: warning: ignoring file /usr/local/lib/libSDLmain.a, file was built for archive which is not the architecture being linked (i386)
ld: warning: ignoring file /usr/local/lib/libSDL.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
"_main", referenced from:
start in crt1.10.6.o
(maybe you meant: _SDL_main)
"_SDL_Init", referenced from:
_SDL_main in movehead.cpp.o
"_SDL_NumJoysticks", referenced from:
_SDL_main in movehead.cpp.o
"_SDL_JoystickEventState", referenced from:
_SDL_main in movehead.cpp.o
"_SDL_JoystickOpen", referenced from:
_SDL_main in movehead.cpp.o
"_SDL_JoystickName", referenced from:
_SDL_main in movehead.cpp.o
"_SDL_JoystickNumAxes", referenced from:
_SDL_main in movehead.cpp.o
"_SDL_PollEvent", referenced from:
_SDL_main in movehead.cpp.o
"_SDL_JoystickGetButton", referenced from:
_SDL_main in movehead.cpp.o
"_SDL_JoystickGetAxis", referenced from:
_SDL_main in movehead.cpp.o
"_SDL_QuitSubSystem", referenced from:
_SDL_main in movehead.cpp.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [sdk/bin/movehead] Error 1
make[1]: *** [CMakeFiles/movehead.dir/all] Error 2
make: *** [all] Error 2
[ERROR]
Error occured when building project movehead
dhcp47-122:movehead yukke150$ sudo qibuild configure -c naoqi-sdk movehead --disable-assembly
usage: qibuild [-h]
lipo -info /usr/local/lib/libSDL.dylib
Non-fat file: /usr/local/lib/libSDL.dylib is architecture: x86_64
lipo -info /usr/local/lib/libSDLmain.a
input file /usr/local/lib/libSDLmain.a is not a fat file
Non-fat file: /usr/local/lib/libSDLmain.a is architecture: x86_64
I think these file are x86_64.
How to fix?
Use the framework distribution of SDL (provided on SDL website) work for me to compile in either x86 or x86_64.
Previously I installed it from brew, so if same (or Mac Port, etc) don't forget to uninstall those first.
I have mad my own CMakeLists.txt file to build OpenNI samples. I successfully build NiSimpleViewer. But when try with NiUserTracker I get this error:
35 warnings generated.
Linking CXX executable main
ld: warning: path '/usr/lib/libOpenNI.dylib' following -L not a directory
Undefined symbols for architecture x86_64:
"DrawDepthMap(xn::DepthMetaData const&, xn::SceneMetaData const&)", referenced from:
glutDisplay() in main.cpp.o
"MyPoseInProgress(xn::PoseDetectionCapability&, char const*, unsigned int, XnPoseDetectionStatus, void*)", referenced from:
_main in main.cpp.o
"MyCalibrationInProgress(xn::SkeletonCapability&, unsigned int, XnCalibrationStatus, void*)", referenced from:
_main in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [main] Error 1
make[1]: *** [CMakeFiles/main.dir/all] Error 2
make: *** [all] Error 2
This is the CMakeLists I use. Plese tell me what's wrong with it?
http://pastebin.com/SMYjjU35
The contents of folder outside build/ are
CMakeLists.txt Libs build opengles.cpp
GL SceneDrawer.cpp glh opengles.h
GLES SceneDrawer.h main.cpp
I guess, it's because of this line:
link_directories(${OPENNI_LIBRARY})
The link_directories() command sets path where libraries should be searched for, so you need something like ${OPENNI_LIBRARY_DIRS} there.