cmake,make , Cmake - not creating the dynamic links

Cmake - not creating the dynamic links


Tag: cmake,make

The project that I am compiling is not linking my shared object file to the main program. This can be confirmed by doing the ldd command on my executable and seeing it say => not found.

Inside my CMakeLists.txt file I have:

add_library(ba SHARED "/usr/local/include/libba.cpp" "/usr/local/include/libba.h")
target_link_libraries(ba (list of other libraries that link to ba))
add_executable(run "/usr/local/main/run.cpp")
target_link_libraries(run ba)


ldd reports what the run-time linker can find.

If you see in the output it means the binary is linked to the library.

The "not found" means the run-time linker can't find that library (i.e. you don't have it installed in a normal system location).

So you can either install your library to a system location, configure your run-time linker to know about your custom location, link your application statically, or use an rpath in your binary to have it give the run-time linker additional places to look for just itself.


Autodependency generation in makefiles

I am trying to understand how autodependency is generated in makefiles in the given link, i cannot understand the following piece of code: DEPDIR = .deps df = $(DEPDIR)/$(*F) SRCS = foo.c bar.c ... %.o : %.c @$(MAKEDEPEND); \ cp $(df).d $(df).P; \ sed -e 's/#.*//' -e 's/^[^:]*: *//' -e...

How to install shared library and include files manually in linux?

I am trying to build and install TBB library from source so that it can be used for OpenCV to take advantages of multiple cores on my raspberry pi. I was able to build TBB from source without any problems using this steps. (Source : How do I build OpenCV...

How to change the name of the output binary to not be a.out with CMake?

Where would I go within CMakeLists.txt in order to change the name of the generated file?

basic makefile ifeq how to

I am just learning about Makefiles and am having trouble with ifeq. Version = GNU Make 3.82 Here is my simple Makefile: CHECK := 0 CHECK2 := 0 check : @echo "Check=${CHECK}" @echo "Check2=${CHECK2}" ifeq (${CHECK2},${CHECK}) @echo "EQUAL" else @echo "NOT EQUAL" endif Here is the output: Check=0 Check2=0 NOT...

How can I configure CMake generated Eclipse project's Build Command and Project Paths?

Our project uses CMake to configure our code. We use Ninja along with a distributed build system. A number of people on our team use Eclipse CDT. We run CMake with the "Eclipse CDT4 - Ninja" generator and the result is generally pretty good. The issues is that any time...

A make rule for verbosity

Typically we have this in a Makefile %.o:%.c $(cc) $(flags) -o [email protected] -c $< When the amount of flags is huge, I feel better to write this instead %.o:%.c $(info $(cc): $< --> [email protected]) @$(cc) $(flags) -o [email protected] -c $< However it can be useful to sometime see everything. So...

How does MAKE remember the file timestamps

I've found this question which is basically asking the same, but got no real answer. Where is the make's config file / database file where it remembers the file timestamps, so it can tell what changed? I checked and there's no .make or similar in my project, nor in the...

Linker error while building from source code

I am trying to build an application from source. I am able to configure it using 'cmake .'. However, when I run 'make' it gives me this: Linking CXX executable ../../bin/lux64/Release/od_batch_launcher ../../bin/lux64/Release/ undefined reference to `dlopen' ../../bin/lux64/Release/ undefined reference to `dlclose' ../../bin/lux64/Release/ undefined reference to `dlerror' ../../bin/lux64/Release/ undefined reference to...

Add LLVM to project using cmake

I'm trying to add LLVM to a cmake project, using cygwin as a compiler. I downloaded LLVM from cygwin's installer (just installed all of the llvm related packages). The files are there, however I cannot include LLVM in my project. I tried using the official guide for 3.5.2 (the version...

make: *** No rule to make target 'rm', needed by 'clean.Stop

I am working with cygwin on windows 8.1. I have used the following make file .SUFFIXES : .o .C CFLAGS = -g2 CC =g++ ${CFLAGS} LIBRARIES = -lm .C.o : ${CC} -c $< SOURCE-FILES = sparsegraph.C myvarious.C pairlist.C graphlist.C peo.graph.C choldc.C copy.C metropolis_fns.C likelihood.C metropolis.C OBJECT-FILES = sparsegraph.o myvarious.o pairlist.o...

Haskell make recipe fails for Paradox theorem prover using GHC

I am trying to install the paradox theorem prover sourced from here. When I run the makefile this is the command that runs: ghc -optl -static -lstdc++ -I../instantiate -I../minisat/current-base ../minisat/current-base/Solver.or ../minisat/current-base/Prop.or ../instantiate/MiniSatWrapper.or ../instantiate/MiniSatInstantiateClause.or -fglasgow-exts -O2 -static -threaded -main-is Paradox.Main.main --make Paradox.Main -o paradox And it results in several errors like...

what does -wl, --start-group mean in make file?

I have this in my Make file.. # Create list of object files # LIB_OBJS = -Wl,--start-group \ $(T_OBJ_DIR)/Source1.o \ $(T_OBJ_DIR)/Source2.o \ $(T_OBJ_DIR)/Source3.o \ $(T_OBJ_DIR)/Source4.o \ $(T_OBJ_DIR)/Source5.o \ -Wl,--end-group \ Could anyone please explain What "-Wl,--start-group" and "-Wl,--end-group" mean?...

What does $(@:.h=.h.d) mean in GNU make?

I'm maintaining a (horrendously complicated) Makefile, and in some recipes I saw the following: $(@:.h=.h.d) I have absolutely no clue as to how to interpret this, or whether there's any documentation on those characters. Obviously, Google won't work because it thinks I'm typing gibberish. I saw a related question about...

Eclipse Makefile: Make Variables are skipped

I have a project with a Makefile in it, on Unix console it works fine, compiles, builds and I can run the binary at the end. I imported the project into Eclipse workspace and somehow Makefile module of Eclipse cannot build the project now. It gives the following error: g++:...

How to build a './configure && make && make install' software against a custom library which I also build?

I am building tmux-2.0 from sources on a pretty regular Linux host. First attempt failed as it turned out that the version of libevent installed is older than required, so I proceeded to download and build libevent-2.0.22 from sources (current at the time of writing) first. Building of libevent succeeded...

c++: Undefined reference to ERROR

I want to add new c++ library of cpd ( to one project in ROS. I have already successfully installed the cpd library in my Ubuntu OS. Now I want to use it under ROS environment. In the CMakeList.txt file, I already added the line of find_package(CPD REQUIRED) include_directories(include ${catkin_INCLUDE_DIRS}...

Cmake and Qt5 linking error

I'm trying to build a Qt5 project with Cmake in order to add some new librairies. The cmake goes well but I have a linking issue when building : Linking CXX executable bin/qGo CMakeFiles/qGo.dir/src/main.cpp.o: dans la fonction « main »: main.cpp:(.text+0x102b): undefined reference to « qInitResources_application() » collect2: error: ld...

CMake simple MVC structure

I have a simple question about how to organize my simple MVC application in C++. I'm new to CMake and I'm just learning how to use it. Imagine a simple folder organization like the following: -Can someone please tell me if this structure is correct? -If so what is the...

Two different CMake difinitions

With CMake when some definitions are defined they are defined in this way: add_definitions(-DMY_DEFINITION) Sometimes I see people make the definitions in a different way: add_definitions(-DMY_DEFINITION=1) Then my question is what's the difference between them in the generated C++ project. Thanks. ...

how to make sure that cmake codes will run after subdirs

Just give a small example to illustrate my problem: project(Test) set(TestLibName mytest) subdirs(src) # will generate mytest.dll dynamic library set_property(TARGET ${TestLibName} PROPERTY FOLDER "test") In this small script, I want to generate the dynamic library with the CMakeLists.txt file in src foler, and after that I will set the library's...

makefile read reused variable inside recipe

In trying to implement nonrecursive make, I have a which looks like: ############ # Enter Stack ############ sp := $(sp).x dirstack_$(sp) := $(d) d := $(dir) .. setup things like OBJECTS_$(d), DEPS_$(d), TARGET_$(d), etc ... ############ # Exit Stack ############ -include $(DEPS_$(d)) d := $(dirstack_$(sp)) sp := $(basename $(sp))...

Makefile overriding default implicit rule

Why this rule cannot override the default implicit rule ? When make is invoked like: make myapp (suppose myapp.c is there). The make runs the default command to build and link the program instead the commands defined in this implicit rule: #... omitted code LCUS=$(LIBS)/libcus.a #... omitted code % :...

CMake link shared library

I am trying to link shared library using cmake. The library is located at known location /home/username/lib. I have added find_library to CMakeLists.txt to find the library. By running ccmake I verified that the library was correctly localized. But when I generate makefile and call make I get error: /user/bin/ld:...

Nested For loop in makefile

I am trying to loop through the .c files in a specific directory through the makefile. i used the following code, but it seems not working: DIR= Sources \ Sources_2 @for entry in ${DIR} ; \ do \ @for i in $${entry}/*.c ; \ do \ echo "Processing $${i}"; \...

Dot in front of variables in make files

I am not able to figure out what does a dot . in front of a variable in makefile does. For e.g.: SOURCEDIRS = . $(PROJECTDIRS) $(TARGET_DIRS_CONCAT) vpath %.c $(SOURCEDIRS) It would be great if someone could tell me. Thanks!...

Error : Cmake can't generate openCV

I am trying to instal opencv C++ with codeBlocks in Windows 8 by following this but I am blocked in step 4.when I try to generate Cmake I have this Error : CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not...

Cannot link to sublibrary/internal library/embedded library with CMake's Visual Studio generator

The full error is available at AppVeyor. I create a library using CMake's add_library command, but when I try to compile another target to this library, I get silly errors like LINK : fatal error LNK1104: cannot open file '..\Debug\boost_http.lib' [C:\projects\boost-http\build\test\algorithm.vcxproj]. Other CMake generators do fine. How to properly handle...

make error during building webkitgtk

I use UBuntu 14.04 LTS. I need to build webkitgtk 2.8.3 Here is an example instruction which I have used: linuxfromscratch When I run sudo make -j8 I get following log: Scanning dependencies of target JavaScriptCore-4-gir Scanning dependencies of target fake-generated-webkitdom-headers [ 0%] Scanning dependencies of target WebKit2-fake-api-headers Scanning dependencies...

Protobuf cannot be linked on ubuntu

I try to use protobuf but somehow the linking fails (here just snippet): Linking CXX executable app CMakeFiles/app.dir/ In function `evoswarm::protobuf_AssignDesc_a_5fto_5fb_2eproto()': undefined reference to `google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(google::protobuf::Descriptor const*, google::protobuf::Message const*, int const*, int, int, int, int, int, int)' undefined reference to...

CMake and CTest: automatically run test's dependencies

In my CMakeLists.txt I have something like this: set_property(TEST testX APPEND PROPERTY DEPENDS testY) set_property(TEST testX APPEND PROPERTY DEPENDS testZ) And I want some way to run testX and all its dependencies automatically. Something like: ctest <options> testX and as a result, CTest will run textY, testZ and testX. Is...

Unable to build GLFW with CMake errors

I downloaded the latest GLFW source (3.1.1) from its site, uncompressed it to the desktop, and tried to build it with cmake. Some dependency errors popped up, but was quickly fixed. Until I got stuck on this one: [email protected]:~/Desktop/glfw-3.1.1$ cmake . -- The C compiler identification is Clang 3.6.0 --...

Reuse jquery plugin without conflict

I have a little plugin working as a progressbar. the problem is: I can't update progressbar's value because every change I made, affect just the last object created =( also.. if I call it as: $(node-selector).progBar().setValue() it works calling the correct node but it loss the config object follow the...

Why does CMake FILE(READ) ignore commas in my file?

I have a css file (which I want to parse and adapt for Qt, but that's not the problem). Let's say this one: QLineEdit:hover:not(focus), QWidget QPlainTextEdit:not(hover):not(focus) { border-color: #5575b0; } I made a CMake script to replace not(...) by !... : that part of the script works correctly. The problem...

Can Make be made to understand that a/../z and b/../z are the same location?

I have a somewhat large and complex Makefile setup that postprocesses some data files. Overall it work quite well, but I have run into an annoying issue where Make builds the same target many times over under different directory names. As a simple example, consider the Makefile foo : 1/foo...

What does the following makefile command do? /no-symbols-control-file

I cam across the following command in a makefile: %-nosyms.$(TARGET).elf: $(PROJECT_OBJECTFILES) $(INTERRUPT_OBJECTFILES) contiki-$(TARGET).a $(CC) $(CFLAGS) -o [email protected] $(filter-out %.a,$^) $(filter %.a,$^) $(filter %.a,$^) $(LDFLAGS) Source: Contiki/cpu/arm/stm32f103/Makefile.stm32f103 . Does this command generate no-symbols-control-file? What is the use of a no symbol image file?...

What's the difference between [email protected] and $1 when there is only one parameter?

There are some C code: apple.c #include<stdio.h> int main(void) { printf("apple\n"); return 0; } Makefile apple: gcc -c [email protected] gcc [email protected] -o [email protected] $ make apple and it works perfectly. But if I modify Makefile as: apple: gcc -c $1.c gcc $1.o -o $1 $ make apple It does not...

Link target to libraries

I have a "CMakified" version of CryptoPP and I am using CMake-GUI to create a MakeFile which ming-make could process as shown in the image below. The "MakeFile" creation was successful but when I executed mingw32-make.exe I got below errors at the very end. Linking CXX executable cryptest.exe CMakeFiles\cryptest.dir/objects.a(test.cpp.obj):test.cpp:(.text+0x8e82): undefined...

CMake to find path to a file which its name contains a certain string

So I am writing a CMake module to find some libraries which is being used a lot in our company. These libraries all have different versions and are such a mess here. In a certain library, even the name of header files and binary files don't match. So I am...

Valgrind changes working directory with CTest in KDevelop

I am starting a test with Helgrind using Ctest: find_program(VALGRIND_EXECUTABLE valgrind) message(STATUS "Valgrind in ${VALGRIND_EXECUTABLE}") configure_file(project.supp project.supp) set(BOOST_TEST_ARGS --catch_system_errors=no) set(VALGRIND_HELGRIND_OPTIONS --tool=helgrind --suppressions=${CMAKE_CURRENT_BINARY_DIR}/project.supp --xml=yes --read-var-info=yes) add_test(NAME TestHelgrind COMMAND ${VALGRIND_EXECUTABLE} ${VALGRIND_HELGRIND_OPTIONS} --xml-file=${CMAKE_CURRENT_BINARY_DIR}/test.xml...

Having issues with using libraries and CMake

C:\Program Files (x86)\JetBrains\CLion 1.0.1\bin\cmake\bin\cmake.exe" --build C:\Users\Anthony\.clion10\system\cmake\generated\d04e461a\d04e461a\Debug --target all -- -j 8 -- Configuring incomplete, errors occurred! CMake Error at CMakeLists.txt:19 (add_library): See also "C:/Users/Anthony/.clion10/system/cmake/generated/d04e461a/d04e461a/Debug/CMakeFiles/CMakeOutput.log". add_library cannot create target "Majick" because another target with the same name already exists. The existing target is an executable created in source directory...

xcode 6.3.2 external build

I'm trying to compile an existing c++ project, originally developed on linux with gcc. The only external library is GSL (GNU Scientific Library). I have created an external build tool project to use xcode's debugger, but I currently have two issues. 1) When I try to build in xcode it...

Cmake errors: The CXX Compiler identification is unknown, The C compiler identification is unknown

I'm trying to install OpenCV on Fedora 21 with a cross compiler for ARM processor. However, when i try to configure using Cmake 3.03, it gives the error: *The CXX compiler identification is unknown The C compiler identification is unknown Check for working CXX compiler: /opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-g++ Check for working CXX...

Why does gcc search header files from non-exist folders?

I am trying to build an open source project shark on CentOS 7, and get very weird build errors: make: *** No rule to make target `/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdarg.h', needed by `core/luv/luv.o'. make: *** No rule to make target `/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h', needed by `core/luv/luv.o'. make: *** No rule to make target `/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed/limits.h', needed...

Cannot link Boost to CMake-based project on VS2015 RC

It gives the error: LINK : fatal error LNK1104: cannot open file 'boost_unit_test_framework-vc140-mt-gd-1_58.lib' [C:\projects\boost-http\build\algorithm.vcxproj] You can see the full error at AppVeyor. The build script (CMakeLists.txt and how cmake is invoked) can be found on the project repository. I've tried a lot, but nothing seems to help. Documentation doesn't help...

Avr-g++ compilation failed with Make Error 1

I'm trying to compile arduino code in Eclipse. Below is build log. make all Building file: ../test.cpp Starting C++ compile "/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=163 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I"/opt/arduino-1.6.3/hardware/arduino/avr/cores/arduino" -I"/opt/arduino-1.6.3/hardware/arduino/avr/variants/standard" -I/usr/lib/avr/include -MMD -MP -MF"test.cpp.d" -MT"test.cpp.d" -D__IN_ECLIPSE__=1 -x c++ "../test.cpp" -o...

How do I list the defined make targets from the command line?

I feel almost silly for asking this but I couldn't find anything on this... Suppose I have a cmake project containing a number of targets: libraries, executables, external targets, ... . How do I list them using the cmake command line interface. I want a list of things that are...

How to correctly make install of binaries and data after compile in linux?

After make of sources I have compiled executable file and data directory with images for it. What should I do at "make install" phase to correctly install these files to the linux system? And how then application can find installed data (in case when binary and data are placed in...

Building vtk with QT5 windows 8

I'm facing a rather weird error. I can see on the wiki that we can build vtk with support for qt5. However, when trying to do so and first configuring with cmake I get the following output: CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/FindQt4.cmake:1326 (message): Found unsuitable Qt version "5.4.2" from...

How to deal with libraries like Boost when cross compiling for arm?

I'd like to cross compile from my AMD64 desktop to ARM7 for Beagleboard Black. So I started with this to get the cross compilers installed: sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf I also created a cmake toolchain file: set (CMAKE_SYSTEM_NAME Linux) set (CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) set (CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) When I run cmake,...