Cannot build and debug project using either Codeblocks or Qtcreator - c++

I am trying to build from scratch Mince on Ubuntu 14.04 x64 using an IDE(either Qtcreator or Codeblocks) because I want to debug the source, to understand how it works better.
Repository: https://github.com/Kingsford-Group/mince/
EDIT: since I found a workaround to build the project externally using -pthread I wonder if editing the file invoked by the make command would allow me to build from one of the IDE and debug the code.
I use cmake-gui with
BOOST_THREAD_LIBRARY: /usr/lib/x86_64-linux-gnu/libpthread.a
CMAKE_BUILD_TYPE:
CMAKE_INSTALL_PREFIX: /home/federico/bioinfo/Mince
and get this:
Boost version: 1.54.0
Found the following Boost libraries:
iostreams
filesystem
system
thread
timer
program_options
serialization
BOOST INCLUDE DIR = /usr/include
BOOST INCLUDE DIRS = /usr/include
BOOST LIB DIR = /usr/lib/x86_64-linux-gnu
BOOST LIBRAREIS = /usr/lib/x86_64-linux-gnu/libboost_iostreams.a;/usr/lib/x86_64-linux-gnu/libboost_filesystem.a;/usr/lib/x86_64-linux-gnu/libboost_system.a;/usr/lib/x86_64-linux-gnu/libboost_thread.a;/usr/lib/x86_64-linux-gnu/libboost_timer.a;/usr/lib/x86_64-linux-gnu/libboost_program_options.a;/usr/lib/x86_64-linux-gnu/libboost_serialization.a;/usr/lib/x86_64-linux-gnu/libpthread.a
Build system will fetch and build the Cereal serialization library
==================================================================
Build system will fetch and build Jellyfish
==================================================================
Found Intel TBB
TBB_LIBRARIES = /usr/lib/libtbb.so;/usr/lib/libtbbmalloc.so
CPACK_SOURCE_IGNORE_FILES = /build/;/bin/;/lib/;/external/;/src/obsolete/;/include/obsolete/;.git/
TBB_LIBRARIES = /usr/lib/libtbb.so;/usr/lib/libtbbmalloc.so
Boost_LIBRARIES = /usr/lib/x86_64-linux-gnu/libboost_iostreams.a;/usr/lib/x86_64-linux-gnu/libboost_filesystem.a;/usr/lib/x86_64-linux-gnu/libboost_system.a;/usr/lib/x86_64-linux-gnu/libboost_thread.a;/usr/lib/x86_64-linux-gnu/libboost_timer.a;/usr/lib/x86_64-linux-gnu/libboost_program_options.a;/usr/lib/x86_64-linux-gnu/libboost_serialization.a;/usr/lib/x86_64-linux-gnu/libpthread.a
Configuring done
Generating done
Then I use # make and get:
...
...
...
...
[ 67%] Built target minceutils
make -f src/CMakeFiles/canoncmp.dir/build.make src/CMakeFiles/canoncmp.dir/depend
make[2]: ingresso nella directory "/home/federico/bioinfo/Mince/build"
cd /home/federico/bioinfo/Mince/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/federico/bioinfo/Mince /home/federico/bioinfo/Mince/src /home/federico/bioinfo/Mince/build /home/federico/bioinfo/Mince/build/src /home/federico/bioinfo/Mince/build/src/CMakeFiles/canoncmp.dir/DependInfo.cmake --color=
Scanning dependencies of target canoncmp
make[2]: uscita dalla directory "/home/federico/bioinfo/Mince/build"
make -f src/CMakeFiles/canoncmp.dir/build.make src/CMakeFiles/canoncmp.dir/build
make[2]: ingresso nella directory "/home/federico/bioinfo/Mince/build"
/usr/bin/cmake -E cmake_progress_report /home/federico/bioinfo/Mince/build/CMakeFiles 1
[ 71%] Building CXX object src/CMakeFiles/canoncmp.dir/CanonicalCompare.cpp.o
cd /home/federico/bioinfo/Mince/build/src && /usr/bin/c++ -DHAVE_LOGGER -funroll-loops -fPIC -O3 -DHAVE_ANSI_TERM -DHAVE_SSTREAM -DHAVE_CONFIG_H -Wall -std=c++11 -Wno-unused-local-typedefs -I/home/federico/bioinfo/Mince/include -I/home/federico/bioinfo/Mince/external -I/home/federico/bioinfo/Mince/external/cereal/include -I/home/federico/bioinfo/Mince/external/install/include -I/home/federico/bioinfo/Mince/external/install/include/jellyfish-2.1.3 -o CMakeFiles/canoncmp.dir/CanonicalCompare.cpp.o -c /home/federico/bioinfo/Mince/src/CanonicalCompare.cpp
In file included from /home/federico/bioinfo/Mince/include/MinceUtils.hpp:15:0,
from /home/federico/bioinfo/Mince/src/CanonicalCompare.cpp:20:
/home/federico/bioinfo/Mince/include/ReadLibrary.hpp: In copy constructor ‘ReadLibrary::ReadLibrary(const ReadLibrary&)’:
/home/federico/bioinfo/Mince/include/ReadLibrary.hpp:35:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (size_t i = 0; i < mc; ++i) { libTypeCounts_[i].store(rl.libTypeCounts_[i].load()); }
^
/home/federico/bioinfo/Mince/include/ReadLibrary.hpp: In constructor ‘ReadLibrary::ReadLibrary(ReadLibrary&&)’:
/home/federico/bioinfo/Mince/include/ReadLibrary.hpp:48:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (size_t i = 0; i < mc; ++i) { libTypeCounts_[i].store(rl.libTypeCounts_[i].load()); }
^
/home/federico/bioinfo/Mince/src/CanonicalCompare.cpp: In function ‘std::vector<std::basic_string<char> > parseReadFile(const string&)’:
/home/federico/bioinfo/Mince/src/CanonicalCompare.cpp:37:7: warning: variable ‘isFastq’ set but not used [-Wunused-but-set-variable]
bool isFastq{false};
^
/home/federico/bioinfo/Mince/src/CanonicalCompare.cpp: In function ‘int main(int, char**)’:
/home/federico/bioinfo/Mince/src/CanonicalCompare.cpp:74:13: warning: unused variable ‘nb_threads’ [-Wunused-variable]
const int nb_threads = 10;
^
/home/federico/bioinfo/Mince/src/CanonicalCompare.cpp:75:13: warning: unused variable ‘concurrent_file’ [-Wunused-variable]
const int concurrent_file = 1; // Number of files to read simultaneously
^
/home/federico/bioinfo/Mince/src/CanonicalCompare.cpp:76:13: warning: unused variable ‘max_read_group’ [-Wunused-variable]
const int max_read_group = 100; // Number of reads in each "job" group
^
/home/federico/bioinfo/Mince/src/CanonicalCompare.cpp:82:12: warning: unused variable ‘bucketStringLength’ [-Wunused-variable]
uint32_t bucketStringLength;
^
Linking CXX executable canoncmp
cd /home/federico/bioinfo/Mince/build/src && /usr/bin/cmake -E cmake_link_script CMakeFiles/canoncmp.dir/link.txt --verbose=1
/usr/bin/c++ -DHAVE_LOGGER -funroll-loops -fPIC -O3 -DHAVE_ANSI_TERM -DHAVE_SSTREAM -DHAVE_CONFIG_H -Wall -std=c++11 -Wno-unused-local-typedefs CMakeFiles/canoncmp.dir/CanonicalCompare.cpp.o -o canoncmp -L/home/federico/bioinfo/Mince/lib -L/home/federico/bioinfo/Mince/external/install/lib -rdynamic libminceutils.a -Wl,-Bstatic -lboost_iostreams -lboost_filesystem -lboost_system -lboost_thread -lboost_timer -lboost_program_options -lboost_serialization -lpthread -lz -Wl,-Bdynamic ../../external/install/lib/libjellyfish-2.0.a -lpthread -lm -ltbb -ltbbmalloc -lgomp -lrt -Wl,-rpath,"\$ORIGIN/../lib:\$ORIGIN/../../lib:\$ORIGIN/"
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libpthread.a(ptw-pause.o): nella funzione "__pause_nocancel":
/build/eglibc-MjiXCM/eglibc-2.19/nptl/../sysdeps/unix/syscall-template.S:81: riferimento non definito a "__syscall_error"
/build/eglibc-MjiXCM/eglibc-2.19/nptl/../sysdeps/unix/syscall-template.S:81: riferimento non definito a "__syscall_error"
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libpthread.a(nptl-init.o): nella funzione "__pthread_initialize_minimal_internal":
/build/eglibc-MjiXCM/eglibc-2.19/nptl/nptl-init.c:285: undefined reference to "__libc_setup_tls"
/build/eglibc-MjiXCM/eglibc-2.19/nptl/nptl-init.c:303: undefined reference to "_dl_cpuclock_offset"
/build/eglibc-MjiXCM/eglibc-2.19/nptl/nptl-init.c:419: undefined reference to "_dl_pagesize"
/build/eglibc-MjiXCM/eglibc-2.19/nptl/nptl-init.c:428: undefined reference to "_dl_pagesize"
/build/eglibc-MjiXCM/eglibc-2.19/nptl/nptl-init.c:448: undefined reference to "_dl_init_static_tls"
/build/eglibc-MjiXCM/eglibc-2.19/nptl/nptl-init.c:450: undefined reference to "_dl_wait_lookup_done"
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libpthread.a(nptl-init.o): nella funzione "__pthread_get_minstack":
/build/eglibc-MjiXCM/eglibc-2.19/nptl/nptl-init.c:471: undefined reference to "_dl_pagesize"
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libpthread.a(pthread_create.o): nella funzione "allocate_stack":
/build/eglibc-MjiXCM/eglibc-2.19/nptl/allocatestack.c:475: undefined reference to "_dl_stack_flags"
/build/eglibc-MjiXCM/eglibc-2.19/nptl/allocatestack.c:614: undefined reference to "_dl_stack_flags"
collect2: error: ld returned 1 exit status
make[2]: *** [src/canoncmp] Error 1
make[2]: uscita dalla directory "/home/federico/bioinfo/Mince/build"
make[1]: *** [src/CMakeFiles/canoncmp.dir/all] Errore 2
make[1]: uscita dalla directory "/home/federico/bioinfo/Mince/build"
make: *** [all] Error 2
So I managed to link correctly and run everything by selecting the failing command (i.e.
/usr/bin/cmake -E cmake_link_script CMakeFiles/canoncmp.dir/link.txt --verbose=1
/usr/bin/c++ -DHAVE_LOGGER -funroll-loops -fPIC -O3 -DHAVE_ANSI_TERM -DHAVE_SSTREAM -DHAVE_CONFIG_H -Wall -std=c++11 -Wno-unused-local-typedefs CMakeFiles/canoncmp.dir/CanonicalCompare.cpp.o -o canoncmp -L/home/federico/bioinfo/Mince/lib -L/home/federico/bioinfo/Mince/external/install/lib -rdynamic libminceutils.a -Wl,-Bstatic -lboost_iostreams -lboost_filesystem -lboost_system -lboost_thread -lboost_timer -lboost_program_options -lboost_serialization -lpthread -lz -Wl,-Bdynamic ../../external/install/lib/libjellyfish-2.0.a -lpthread -lm -ltbb -ltbbmalloc -lgomp -lrt -Wl,-rpath,"\$ORIGIN/../lib:\$ORIGIN/../../lib:\$ORIGIN/"
and replace -lpthread with -pthread but since I wanted to understand the code I wanted to open it and build it using Qtcreator or Codeblocks and use the debugger this is not working.
Any help is appreciated
EDIT= Title, since I found a workaround to build the project externally using -pthread I wonder if editing the file invoked by the make command would allow me to build from one of the IDE and debug the code.

Related

Compile *.cpp and *.c with Automake

Structure:
-myProject
-Makefile.am
-configure.ac
-src
-Makefile.am
-main.c
-test.c
-test.h
When I try to compile, I've got the error Undefinded reference to a function from test.c.
Makefile.am:
AUTOMAKE_OPTIONS = foreign
SUBDIRS=src
src/Makefile.am:
bin_PROGRAMS = TEST
AM_CXXFLAGS =-Wall -Wno-psabi -w -pthread -I/usr/local/include
AM_CFLAGS =-Wall -w
#Sources
TEST_SOURCES = test.c main.cpp
TEST_LDADD = #LDFLAGS# -lmosquitto
TEST_LDFLAGS =-lmosquitto
It seem's, that it's not possible to linkt the two sources. Can anybody help me??
ERROR:
make all-recursive
make[1]: Entering directory '/media/sf_Shared/Software/executables/TEST'
Making all in src
make[2]: Entering directory '/media/sf_Shared/Software/executables/TEST/src'
g++ -DHAVE_CONFIG_H -I. -I.. -Wall -Wno-psabi -w -pthread -I/usr/local/include -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.cpp
mv -f .deps/main.Tpo .deps/main.Po
g++ -Wall -Wno-psabi -w -pthread -I/usr/local/include -g -O2 -lmosquitto -o TEST test.o main.o -lmosquitto
/usr/bin/ld: main.o: in function `main':
/media/sf_Shared/Software/executables/TEST/src/main.cpp:564: undefined reference to `open_ports(unsigned int, unsigned int)'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:366: TEST] Error 1
make[2]: Leaving directory '/media/sf_Shared/Software/executables/TEST/src'
make[1]: *** [Makefile:359: all-recursive] Error 1
make[1]: Leaving directory '/media/sf_Shared/Software/executables/TEST'
make: *** [Makefile:300: all] Error 2
I'm including in the main.cpp the test.h. There is the function open_ports declared(u_int32_t open_ports(u_int32_t a, u_int32_t b);), which is implemented in test.c
This is not an automake issue — you are doing the right thing (or at least close to) in the Makefile.am.
The problem is that your symbol is declared without extern "C", but defined only in C, so when the C++ compiler takes your main.cpp, it expects to find a mangled symbols (which encodes the signature of the function, that is the number and types of parameters), rather than a plain (C) one.
You can tell that this is the case because it's looking for open_ports(unsigned int, unsigned int) — rather than just open_ports.
The easiest solution is to change your main.cpp to say:
extern "C" {
#include "test.h"
}
That declares that the test.h header only includes C declarations, which will then generate the right symbol lookup for what you define in test.c.

QT, GDCM lib problems. "Undefined reference to '_imp_ZNgdcmr11ImageReader...'

I want to run GDCM lib (v.3.0.0) using C ++ in the API QT 5.13.1 (MinGW 7.3.0 64-bit) to read DICOM files. This is normal when I include the header files and see all the methods in the libraries. But here
ascending error when I try to run:
undefined reference to '_imp__ZN4gdcm11ImageReaderC1Ev'
Here is what i'am already tried:
include all GDCM libs
downgrade gpp
dcm_reader.pro file
...
INLCUDEPATH += -L'C:\Program Files (x86)\GDCM 3.0\include\gdcm-3.0'
LIBS += -L'C:\Program Files (x86)\GDCM 3.0\bin'
LIBS += -L'C:\Program Files (x86)\GDCM 3.0\lib'
LIBS += -lgdcmcharls -lgdcmCommon -lgdcmDICT -lgdcmDSED -lgdcmexpat -lgdcmIOD -lgdcmjpeg8 -lgdcmjpeg12 -lgdcmjpeg16 -lgdcmMEXD -lgdcmMSFF -lgdcmuuid -lgdcmzlib -lsocketxx
#LIBS += -lgdcmImageReader // Raised error "cannot find -lgdcmImageReader"
main.cpp
incude <gdcmImageReader.h>
int main()
{
gdcm::ImageReader reader; // Error: undefined reference to '_imp__ZN4gdcm11ImageReaderC1Ev'
}
I have suspicions that this error is due to the fact that I do not to have the full version of the libs or that the GDCM librs is not suitable for the QT compliants.
Compile output:
18:15:25: Запускаются этапы для проекта dcm_reader... 18:15:25: Запускается: "C:\Qt\Qt5.13.1\Tools\mingw730_32\bin\mingw32-make.exe" clean -j4 C:/Qt/Qt5.13.1/Tools/mingw730_32/bin/mingw32-make -f Makefile.Debug clean C:/Qt/Qt5.13.1/Tools/mingw730_32/bin/mingw32-make
-f Makefile.Release clean mingw32-make[1]: Entering directory 'C:/Users/user/Documents/build-dcm_reader-Desktop_Qt_5_13_1_MinGW_32_bit-Debug' del debug\moc_predefs.h mingw32-make[1]: Entering directory 'C:/Users/user/Documents/build-dcm_reader-Desktop_Qt_5_13_1_MinGW_32_bit-Debug' del release\moc_predefs.h Н• г§ •вбп ≠ ©в® C:\Users\user\Documents\build-dcm_reader-Desktop_Qt_5_13_1_MinGW_32_bit-Debug\debug\moc_predefs.h Н• г§ •вбп ≠ ©в® C:\Users\user\Documents\build-dcm_reader-Desktop_Qt_5_13_1_MinGW_32_bit-Debug\release\moc_predefs.h del debug\main.o del release\main.o Н• г§ •вбп ≠ ©в® C:\Users\user\Documents\build-dcm_reader-Desktop_Qt_5_13_1_MinGW_32_bit-Debug\release\main.o mingw32-make[1]: Leaving directory 'C:/Users/user/Documents/build-dcm_reader-Desktop_Qt_5_13_1_MinGW_32_bit-Debug' mingw32-make[1]: Leaving directory 'C:/Users/user/Documents/build-dcm_reader-Desktop_Qt_5_13_1_MinGW_32_bit-Debug' 18:15:27: ѕроцесс ЂC:\Qt\Qt5.13.1\Tools\mingw730_32\bin\mingw32-make.exeї завершился успешно. 18:15:27: «апускаетс€: ЂC:\Qt\Qt5.13.1\5.13.1\mingw73_32\bin\qmake.exeї C:\Users\user\Documents\dcm_reader\dcm_reader.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug" 18:15:28: ѕроцесс ЂC:\Qt\Qt5.13.1\5.13.1\mingw73_32\bin\qmake.exeї завершился успешно. 18:15:28: «апускаетс€: ЂC:\Qt\Qt5.13.1\Tools\mingw730_32\bin\mingw32-make.exeї -f C:/Users/user/Documents/build-dcm_reader-Desktop_Qt_5_13_1_MinGW_32_bit-Debug/Makefile qmake_all mingw32-make: Nothing to be done for 'qmake_all'. 18:15:28: ѕроцесс ЂC:\Qt\Qt5.13.1\Tools\mingw730_32\bin\mingw32-make.exeї завершился успешно. 18:15:28: Запускается: "C:\Qt\Qt5.13.1\Tools\mingw730_32\bin\mingw32-make.exe" -j4 C:/Qt/Qt5.13.1/Tools/mingw730_32/bin/mingw32-make -f Makefile.Debug mingw32-make[1]: Entering directory 'C:/Users/user/Documents/build-dcm_reader-Desktop_Qt_5_13_1_MinGW_32_bit-Debug' g++ -c -fno-keep-inline-dllexport -g -std=gnu++11 -Wall -W -Wextra
-fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_CORE_LIB -I..\dcm_reader -I. -I..\..\..\..\Qt\libs\GDCM_3.0\include\gdcm-3.0 -I..\..\..\..\Qt\Qt5.13.1\5.13.1\mingw73_32\include -I..\..\..\..\Qt\Qt5.13.1\5.13.1\mingw73_32\include\QtCore -Idebug -I..\..\..\..\Qt\Qt5.13.1\5.13.1\mingw73_32\mkspecs\win32-g++ -o debug\main.o ..\dcm_reader\main.cpp g++ -Wl,-subsystem,console
-mthreads -o debug\dcm_reader.exe debug/main.o -LC:\Qt\libs\GDCM_3.0\bin -LC:\Qt\libs\GDCM_3.0\lib -lgdcmcharls -lgdcmCommon -lgdcmDICT -lgdcmDSED -lgdcmexpat -lgdcmgetopt -lgdcmIOD -lgdcmjpeg8 -lgdcmjpeg12 -lgdcmjpeg16 -lgdcmmd5 -lgdcmMEXD -lgdcmMSFF -lgdcmzlib C:\Qt\Qt5.13.1\5.13.1\mingw73_32\lib\libQt5Cored.a debug/main.o: In function `main': C:\Users\user\Documents\build-dcm_reader-Desktop_Qt_5_13_1_MinGW_32_bit-Debug/../dcm_reader/main.cpp:5: undefined reference to `_imp___ZN4gdcm11ImageReaderC1Ev' C:\Users\user\Documents\build-dcm_reader-Desktop_Qt_5_13_1_MinGW_32_bit-Debug/../dcm_reader/main.cpp:5: undefined reference to `_imp___ZN4gdcm11ImageReaderD1Ev' collect2.exe: error: ld returned 1 exit status mingw32-make[1]: *** [Makefile.Debug:65: debug/dcm_reader.exe] Error 1 mingw32-make: *** [Makefile:38: debug] Error 2 mingw32-make[1]: Leaving directory 'C:/Users/user/Documents/build-dcm_reader-Desktop_Qt_5_13_1_MinGW_32_bit-Debug' 18:15:31: ѕроцесс ЂC:\Qt\Qt5.13.1\Tools\mingw730_32\bin\mingw32-make.exeї завершился с кодом 2. Ошибка при сборке/разворачивании проекта dcm_reader (комплект: Desktop Qt 5.13.1 MinGW 32-bit) Во время выполнения этапа "Сборка" 18:15:31: ѕрошло времени: 00:05.

Linker error when using cinder and poco

I'm trying to use libcinder to make some visualizations. In integrating in my existing codebase, I've run into some linker errors that I can't figure out.
I've boiled the problem down to a minimal example, with the following results:
cd /build/src && /usr/bin/cmake -E cmake_link_script CMakeFiles/BasicApp.dir/link.txt --verbose=1
/usr/bin/c++ -O3 -DNDEBUG CMakeFiles/BasicApp.dir/BasicApp.cpp.o -o ../bin/BasicApp -rdynamic -lPocoUtil -lPocoFoundation
make[2]: Leaving directory '/build'
[100%] Built target BasicApp
make[1]: Leaving directory '/build'
/usr/bin/cmake -E cmake_progress_start /build/CMakeFiles 0
If don't involve cinder at all, everything works fine, as seen above. if I add my function to the minimal cinder example (BasicApp), I get the following output on compilation:
cd /build/src && /usr/bin/cmake -E cmake_link_script CMakeFiles/BasicApp.dir/link.txt --verbose=1
/usr/bin/c++ -O3 -DNDEBUG CMakeFiles/BasicApp.dir/BasicApp.cpp.o -o ../bin/BasicApp -rdynamic -lPocoUtil -lPocoFoundation /cinder/lib/linux/x86_64/ogl/Release/libcinder.a -lGLU -lGL -lSM -lICE -lX11 -lXext -lXcursor -lXinerama -lXrandr -lXi -lz -lcurl -lfontconfig -lpulse -lmpg123 -lsndfile -lgobject-2.0 -lglib-2.0 -lgstreamer-1.0 -lgstbase-1.0 -lgstapp-1.0 -lgstvideo-1.0 -lgstgl-1.0 /cinder/lib/linux/x86_64//libboost_system.a /cinder/lib/linux/x86_64//libboost_filesystem.a -ldl -lpthread
CMakeFiles/BasicApp.dir/BasicApp.cpp.o: In function `load_images(std::string, std::string, int, int)':
BasicApp.cpp:(.text+0xca2): undefined reference to `Poco::DirectoryIterator::DirectoryIterator(std::string const&)'
BasicApp.cpp:(.text+0xd57): undefined reference to `Poco::DirectoryIterator::DirectoryIterator(std::string const&)'
collect2: error: ld returned 1 exit status
src/CMakeFiles/BasicApp.dir/build.make:118: recipe for target 'bin/BasicApp' failed
make[2]: *** [bin/BasicApp] Error 1
make[2]: Leaving directory '/build'
CMakeFiles/Makefile2:1244: recipe for target 'src/CMakeFiles/BasicApp.dir/all' failed
make[1]: *** [src/CMakeFiles/BasicApp.dir/all] Error 2
make[1]: Leaving directory '/build'
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
I'm assuming that some configuration set in the cinder cmake files is messing things up, but I don't understand why or how to fix it.
This is with gcc version 5.4.0 and cmake version 3.5.1.
Here is a reduced cmake file that has this issue:
cmake_minimum_required(VERSION 3.2)
project(segslam C CXX)
set(CMAKE_CXX_STANDARD 11)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/poco")
find_package(Poco REQUIRED)
#include($ENV{CINDER_PATH}/proj/cmake/configure.cmake)
#set(cinder_DIR $ENV{CINDER_PATH}/${CINDER_LIB_DIRECTORY})
#find_package(cinder REQUIRED PATHS " $ENV{CINDER_PATH}/${CINDER_LIB_DIRECTORY}")
add_executable(BasicApp BasicApp.cpp)
#target_include_directories(BasicApp PUBLIC $ENV{CINDER_PATH}/include)
#target_link_libraries(BasicApp cinder)
target_link_libraries(BasicApp ${Poco_LIBRARIES})
set_target_properties(BasicApp PROPERTIES
DEBUG_POSTFIX "d"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
install(TARGETS BasicApp RUNTIME DESTINATION bin COMPONENT main)
install(FILES ${srcs} DESTINATION app COMPONENT main)
If the commented lines are uncommented, it links in cinder and things break. I'm using a FindPoco.cmake file from here. The cinder cmake files are located here.
It doesn't seem to matter what the linking order is, and none of the other libraries I'm using have this issue.
So it turns out that the issue is an ABI mismatch. Cinder ships with precompiled boost libraries that use a gcc version <5.1, which will cause conflicts if you try to use libraries that have been compiled with gcc version >= 5.1.
My fix was to remove the cinder precompiled boost libraries and recompile with the version of boost in the ubuntu repos.
See this thread on the cinder discourse for more info.

Automake & Autoconf - Program Doesn't Recognize Static Library Just Built

I am developing a library called libspellcheck, and a program that uses it to check spelling called spellcheck. Here is my directory structure:
libspellcheck
-> doc
-> man
-> libspellcheck (libspellcheck source)
-> spellcheck (spellcheck source)
I wanted to use a configure script instead of a plain Makefile as I had been using. Everything goes okay until I try compiling spellcheck:
Making all in libspellcheck
make[1]: Entering directory `/home/iandun/libspellcheck-devel/libspellcheck/libspellcheck'
g++ -DHAVE_CONFIG_H -I. -g -O2 -MT checker.o -MD -MP -MF .deps/checker.Tpo -c -o checker.o checker.cpp
mv -f .deps/checker.Tpo .deps/checker.Po
g++ -DHAVE_CONFIG_H -I. -g -O2 -MT SpellCorrector.o -MD -MP -MF .deps/SpellCorrector.Tpo -c -o SpellCorrector.o SpellCorrector.cpp
mv -f .deps/SpellCorrector.Tpo .deps/SpellCorrector.Po
rm -f libspellcheck.a
ar cru libspellcheck.a checker.o SpellCorrector.o
ranlib libspellcheck.a
make[1]: Leaving directory `/home/iandun/libspellcheck-devel/libspellcheck/libspellcheck'
Making all in spellcheck
make[1]: Entering directory `/home/iandun/libspellcheck-devel/libspellcheck/spellcheck'
g++ -DHAVE_CONFIG_H -I. -g -O2 -MT spellcheck.o -MD -MP -MF .deps/spellcheck.Tpo -c -o spellcheck.o spellcheck.cpp
spellcheck.cpp: In function 'int main(int, char**)':
spellcheck.cpp:111:21: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
char *dictionary = "/etc/english.dict"; //Default Dictionary
^
spellcheck.cpp:164:14: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
dictionary = "/etc/english.dict";
^
mv -f .deps/spellcheck.Tpo .deps/spellcheck.Po
g++ -DHAVE_CONFIG_H -I. -g -O2 -MT meta.o -MD -MP -MF .deps/meta.Tpo -c -o meta.o meta.cpp
mv -f .deps/meta.Tpo .deps/meta.Po
g++ -g -O2 "../libspellcheck/libspellcheck.a" -o spellcheck spellcheck.o meta.o
spellcheck.o: In function `correctMisspelled(std::string, std::string)':
/home/iandun/libspellcheck-devel/libspellcheck/spellcheck/spellcheck.cpp:29: undefined reference to `correctSpelling(std::string, std::string)'
spellcheck.o: In function `doFileCheck(char*, char*, char*, spelling)':
/home/iandun/libspellcheck-devel/libspellcheck/spellcheck/spellcheck.cpp:61: undefined reference to `check_spelling_file(char*, char*, std::string)'
spellcheck.o: In function `main':
/home/iandun/libspellcheck-devel/libspellcheck/spellcheck/spellcheck.cpp:193: undefined reference to `add_word(char*, char*)'
/home/iandun/libspellcheck-devel/libspellcheck/spellcheck/spellcheck.cpp:224: undefined reference to `check_spelling_string(char*, std::string, std::string)'
meta.o: In function `do_about_msg()':
/home/iandun/libspellcheck-devel/libspellcheck/spellcheck/meta.cpp:29: undefined reference to `lib_version()'
collect2: error: ld returned 1 exit status
make[1]: *** [spellcheck] Error 1
make[1]: Leaving directory `/home/iandun/libspellcheck-devel/libspellcheck/spellcheck'
make: *** [all-recursive] Error 1
I put a reference to libspellcheck.a in my Makefile.am file in the spellcheck directory:
CFLAGS = -m32 -Wall
LDFLAGS = "../libspellcheck/libspellcheck.a"
bin_PROGRAMS = spellcheck
spellcheck_SOURCES = spellcheck.cpp meta.cpp
And also changed my references to the spellcheck header file:
#include "../libspellcheck/spellcheck.h"
Here is my Makefile.am in the libspellcheck folder:
CFLAGS = -m32 -Wall
LDFLAGS =
lib_LIBRARIES = libspellcheck.a
libspellcheck_a_SOURCES = checker.cpp SpellCorrector.cpp
include_HEADERS = spellcheck.h SpellCorrector.h
Here is my Makefile.am in the main folder:
AUTOMAKE_OPTIONS = foreign
SUBDIRS = libspellcheck spellcheck man
And my configure.ac:
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT(libspellcheck, 1.25, corinthianmonthly#hotmail.com)
AC_OUTPUT(Makefile libspellcheck/Makefile spellcheck/Makefile man/Makefile)
AC_CONFIG_SRCDIR([])
AC_CONFIG_HEADERS([])
AM_INIT_AUTOMAKE
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
# Checks for libraries.
# Checks for header files.
AC_CHECK_HEADERS([stdlib.h,iostream,fstream,string,stdio.h,sstream,cctype,algorithm,boost/algorithm/string.hpp])
# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
AC_TYPE_SIZE_T
# Checks for library functions.
AC_OUTPUT
What am I doing wrong?
CFLAGS = -m32 -Wall
LDFLAGS = "../libspellcheck/libspellcheck.a"
First, these are user flags. Use the AM_* forms instead.
Second, LDFLAGS is for flags. It is put near the start of the command line. But, for linking, order matters, so you want to use LDADD instead. There are a few ways to do this but perhaps the best is to use the per-target variable:
spellcheck_LDADD = ../libspellcheck/libspellcheck.a
You don't need those quotes.

Error: Compiling simple PjSIP program under ubuntu

I am trying to compile simple PjSIP program under ubuntu. I am getting error as
/usr/bin/ld: cannot find -lpjsua-i686-pc-linux-gnu
What does it mean?
Here is the ouput:-
root#mypc-desktop:/home/mypc/pjsip# make
gcc -o myapp myapp.cpp -DPJ_AUTOCONF=1 -O2 -I/home/mypc/pjproject-1.4.5/pjlib/include -I/home/mypc/pjproject-1.4.5/pjlib-util/include -I/home/mypc/pjproject-1.4.5/pjnath/include -I/home/mypc/pjproject-1.4.5/pjmedia/include -I/home/mypc/pjproject-1.4.5/pjsip/include -L/home/mypc/pjproject-1.4.5/pjlib/lib -L/home/mypc/pjproject-1.4.5/pjlib-util/lib -L/home/mypc/pjproject-1.4.5/pjnath/lib -L/home/mypc/pjproject-1.4.5/pjmedia/lib -L/home/mypc/pjproject-1.4.5/pjsip/lib -L/home/mypc/pjproject-1.4.5/third_party/lib -lpjsua-i686-pc-linux-gnu -lpjsip-ua-i686-pc-linux-gnu -lpjsip-simple-i686-pc-linux-gnu -lpjsip-i686-pc-linux-gnu -lpjmedia-codec-i686-pc-linux-gnu -lpjmedia-i686-pc-linux-gnu -lpjmedia-audiodev-i686-pc-linux-gnu -lpjnath-i686-pc-linux-gnu -lpjlib-util-i686-pc-linux-gnu -lresample-i686-pc-linux-gnu -lmilenage-i686-pc-linux-gnu -lsrtp-i686-pc-linux-gnu -lgsmcodec-i686-pc-linux-gnu -lspeex-i686-pc-linux-gnu -lilbccodec-i686-pc-linux-gnu -lg7221codec-i686-pc-linux-gnu -lportaudio-i686-pc-linux-gnu -lpj-i686-pc-linux-gnu -lm -lnsl -lrt -lpthread
/usr/bin/ld: cannot find -lpjsua-i686-pc-linux-gnu
collect2: ld returned 1 exit status
make: *** [myapp] Error 1
Here is code
#include <pjlib.h>
#include <pjlib-util.h>
#include <pjmedia.h>
#include <pjmedia-codec.h>
#include <pjsip.h>
#include <pjsip_simple.h>
#include <pjsip_ua.h>
#include <pjsua-lib/pjsua.h>
int main()
{
return 0;
}
Here is a Makefile
#Modify this to point to the PJSIP location.
PJBASE=/home/mypc/pjproject-1.4.5
include $(PJBASE)/build.mak
CC = $(APP_CC)
LDFLAGS = $(APP_LDFLAGS)
LDLIBS = $(APP_LDLIBS)
CFLAGS = $(APP_CFLAGS)
CPPFLAGS= ${CFLAGS}
# If your application is in a file named myapp.cpp or myapp.c
# this is the line you will need to build the binary.
all: myapp
myapp: myapp.cpp
$(CC) -o $# $< $(CPPFLAGS) $(LDFLAGS) $(LDLIBS)
clean:
rm -f myapp.o myapp
Thanks
EDIT:
I just noticed that there is a error building PjSIP
make[2]: Entering directory
/home/mypc/pjproject-1.4.5/pjnath/build'
gcc -c -Wall -DPJ_AUTOCONF=1 -O2
-Wno-unused-label -Werror -I../include -I../../pjlib/include -I../../pjlib-util/include \ -o output/pjnath-i686-pc-linux-gnu/stun_session.o
\ ../src/pjnath/stun_session.c cc1:
warnings being treated as errors
../src/pjnath/stun_session.c: In
function ‘apply_msg_options’:
../src/pjnath/stun_session.c:230:
error: suggest parentheses around &&
within || make[2]: ***
[output/pjnath-i686-pc-linux-gnu/stun_session.o]
Error 1 make[2]: Leaving directory
/home/mypc/pjproject-1.4.5/pjnath/build'
make[1]: * [pjnath] Error 2 make[1]:
Leaving directory
`/home/mypc/pjproject-1.4.5/pjnath/build'
make: * [all] Error 1
When I tried to find -Werror in make files present at /home/mypc/pjproject-1.4.5/pjnath/build, $(PJDIR)/build.mak and $(PJDIR)/build/common.mak its not present there anybody know where it could be ?
It seems that the pj* can't build the neccessary libaries - for a simple fix try to locate the line in /home/mypc/pjproject-1.4.5/build.mak where -Werror is added to $(APP_CFLAGS) and remove it (the -Werror, not the whole line if other flags are added :).
Alternatively apply the fix suggested by gcc on line 230 in src/pjnath/stun_session.c.
edit:
Just read that you found no -Werror. Could you either paste line 230 of stun_session.c or the make-files somewhere?
The source line would be preferred.