Undefined reference to klee when building s2e - cmake

I'm trying to start a new prject and build s2e in a new directory. But at arounf the 100% mark, it gives me an undefined reference error. The relevant part (imo) is this:
[ 92%] Linking CXX executable ../ExprTest
../../lib/libkleeCore.a(Executor.cpp.o): In function `klee::Executor::setModule(llvm::Module*, klee::Interpreter::ModuleOptions const&, bool)':
~/s2e_projects/source/s2e/klee/include/klee/Internal/Module/KModule.h:189: undefined reference to `klee::KModule::KModule(llvm::Module*)'
My directory structure is such:
|-s2e-env
|-s2e_projects
|-venv
I followed the steps from here: http://s2e.systems/docs/s2e-env.html I followed all the steps upto s2e build which is where this problem occurs.
For reference, the (truncated) output which I got from doing s2e build &> log:
[ 88%] Built target kleeModule
make[3]: Entering directory '~/s2e_projects/build/klee-release'
make[3]: Entering directory '~/s2e_projects/build/klee-release'
make[3]: Entering directory '~/s2e_projects/build/klee-release'
make[3]: Leaving directory '~/s2e_projects/build/klee-release'
make[3]: Leaving directory '~/s2e_projects/build/klee-release'
make[3]: Leaving directory '~/s2e_projects/build/klee-release'
make[3]: Entering directory '~/s2e_projects/build/klee-release'
make[3]: Entering directory '~/s2e_projects/build/klee-release'
make[3]: Entering directory '~/s2e_projects/build/klee-release'
[ 91%] Linking CXX executable ../ADTTest
[ 91%] Linking CXX executable ../UtilsTest
[ 92%] Linking CXX executable ../ExprTest
../../lib/libkleeCore.a(Executor.cpp.o): In function `klee::Executor::setModule(llvm::Module*, klee::Interpreter::ModuleOptions const&, bool)':
~/s2e_projects/source/s2e/klee/include/klee/Internal/Module/KModule.h:189: undefined reference to `klee::KModule::KModule(llvm::Module*)'
../../lib/libkleeCore.a(Executor.cpp.o): In function `klee::Executor::setModule(llvm::Module*, klee::Interpreter::ModuleOptions const&, bool)':
~/s2e_projects/build/llvm-10.0.0.src/include/llvm/IR/DataLayout.h:393: undefined reference to `llvm::DataLayout::getPointerSize(unsigned int) const'
../../lib/libkleeCore.a(Executor.cpp.o): In function `klee::Executor::setModule(llvm::Module*, klee::Interpreter::ModuleOptions const&, bool)':
~/s2e_projects/source/s2e/klee/lib/Core/Executor.cpp:107: undefined reference to `klee::KModule::linkLibraries(klee::Interpreter::ModuleOptions const&)'
~/s2e_projects/source/s2e/klee/lib/Core/Executor.cpp:108: undefined reference to `klee::KModule::buildShadowStructures()'
~/s2e_projects/source/s2e/klee/lib/Core/Executor.cpp:110: undefined reference to `klee::KModule::prepare(klee::Interpreter::ModuleOptions const&, klee::InterpreterHandler*)'
../../lib/libkleeCore.a(Executor.cpp.o): In function `klee::Executor::initializeGlobalObject(klee::ExecutionState&, boost::intrusive_ptr<klee::ObjectState> const&, llvm::Constant const*, unsigned int)':
~/s2e_projects/source/s2e/klee/lib/Core/Executor.cpp:150: undefined reference to `llvm::ConstantDataSequential::getNumElements() const'
~/s2e_projects/source/s2e/klee/lib/Core/Executor.cpp:151: undefined reference to `llvm::ConstantDataSequential::getElementAsConstant(unsigned int) const'
~/s2e_projects/source/s2e/klee/lib/Core/Executor.cpp:153: undefined reference to `llvm::DataLayout::getStructLayout(llvm::StructType*) const'
~/s2e_projects/source/s2e/klee/lib/Core/Executor.cpp:158: undefined reference to `klee::KModule::evalConstant(std::unordered_map<llvm::GlobalValue const*, klee::ref<klee::ConstantExpr>, std::hash<llvm::GlobalValue const*>, std::equal_to<llvm::GlobalValue const*>, std::allocator<std::pair<llvm::GlobalValue const* const, klee::ref<klee::ConstantExpr> > > > const&, llvm::Constant const*, klee::KInstruction const*)'
~/s2e_projects/source/s2e/klee/lib/Core/Executor.cpp:163: undefined reference to `klee::ConstantExpr::ZExt(unsigned int)'
../../lib/libkleeCore.a(Executor.cpp.o): In function `klee::Executor::initializeGlobals(klee::ExecutionState&)':
~/s2e_projects/source/s2e/klee/lib/Core/Executor.cpp:200: undefined reference to `llvm::Value::getName() const'
~/s2e_projects/source/s2e/klee/lib/Core/Executor.cpp:241: undefined reference to `llvm::Value::getName() const'
~/s2e_projects/source/s2e/klee/lib/Core/Executor.cpp:247: undefined reference to `llvm::GlobalValue::isDeclaration() const'
~/s2e_projects/source/s2e/klee/lib/Core/Executor.cpp:258: undefined reference to `llvm::Value::getName() const'
~/s2e_projects/source/s2e/klee/lib/Core/Executor.cpp:260: undefined reference to `llvm::Value::getName() const'
~/s2e_projects/source/s2e/klee/lib/Core/Executor.cpp:262: undefined reference to `llvm::Value::getName() const'
~/s2e_projects/source/s2e/klee/lib/Core/Executor.cpp:268: undefined reference to `llvm::Value::getName() const'
~/s2e_projects/source/s2e/klee/lib/Core/Executor.cpp:281: undefined reference to `llvm::Value::getName() const'
~/s2e_projects/source/s2e/klee/lib/Core/Executor.cpp:306: undefined reference to `klee::KModule::evalConstant(std::unordered_map<llvm::GlobalValue const*, klee::ref<klee::ConstantExpr>, std::hash<llvm::GlobalValue const*>, std::equal_to<llvm::GlobalValue const*>, std::allocator<std::pair<llvm::GlobalValue const* const, klee::ref<klee::ConstantExpr> > > > const&, llvm::Constant const*, klee::KInstruction const*)'
~/s2e_projects/source/s2e/klee/lib/Core/Executor.cpp:311: undefined reference to `llvm::Value::getName() const'
../../lib/libkleeCore.a(Executor.cpp.o): In function `klee::Executor::initializeGlobals(klee::ExecutionState&)':
~/s2e_projects/build/llvm-10.0.0.src/include/llvm/IR/GlobalVariable.h:92: undefined reference to `llvm::GlobalValue::isDeclaration() const'
../../lib/libkleeCore.a(Executor.cpp.o): In function `klee::Executor::initializeGlobals(klee::ExecutionState&)':
...

I had the exact same error and solved it with:
sudo apt install gcc-9 g++-9
Also check to make sure clang selects the installed gcc-9 toolchain:
$ PATH_TO_S2E/install/bin/clang++ -v
...
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9
...
As for why a compatible gcc toolchain is needed, even though clang is used to compile S2E:
Why clang selects a gcc installation?

Related

Linking C++ on Rust: undefined reference to `operator delete(void*)' and `__gxx_personality_v0', libstdc++ missing?

I'm trying to build a cpp cmake project and link to my Rust project.
cmake_minimum_required(VERSION 3.0)
set (CMAKE_CXX_STANDARD 17)
project(ZLMediaKit_LIB CXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(ENABLE_TESTS OFF FORCE)
option(ENABLE_TESTS OFF)
set(ENABLE_OPENSSL FALSE FORCE)
option(ENABLE_OPENSSL OFF)
add_subdirectory(ZLMediaKit)
add_library(libzlmediakit_cpp_interface STATIC interface.cpp)
target_include_directories(libzlmediakit_cpp_interface PUBLIC
.
${CMAKE_CURRENT_SOURCE_DIR}/ZLMediaKit/src
${CMAKE_CURRENT_SOURCE_DIR}/ZLMediaKit/3rdpart/ZLToolKit/src)
target_link_libraries(libzlmediakit_cpp_interface zlmediakit zltoolkit mpeg mov flv libstdc++)
install(TARGETS libzlmediakit_cpp_interface DESTINATION .)
Here's my build.rs:
extern crate cmake;
use cmake::Config;
fn main()
{
let dst = Config::new("zlmediakit_lib").build();
println!("cargo:rustc-link-search=native={}", dst.display());
println!("cargo:rustc-link-lib=static=libzlmediakit_cpp_interface");
}
But I'm getting undefined reference errors:
ong)':
/usr/include/c++/9/ext/new_allocator.h:128: undefined reference to `operator delete(void*)'
/usr/bin/ld: /home/dev/orwell/liborwell_rust/zlmediakit_rust/target/debug/build/zlmediakit_rust-499cc82f14515635/out/liblibzlmediakit_cpp_interface.a(interface.cpp.o): in function `ZLRTSPClient::~ZLRTSPClient()':
/home/dev/orwell/liborwell_rust/zlmediakit_rust/zlmediakit_lib/ZLRTSPClient.h:14: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/usr/bin/ld: /home/dev/orwell/liborwell_rust/zlmediakit_rust/target/debug/build/zlmediakit_rust-499cc82f14515635/out/liblibzlmediakit_cpp_interface.a(interface.cpp.o): in function `std::default_delete<ZLRTSPClient>::operator()(ZLRTSPClient*) const':
/usr/include/c++/9/bits/unique_ptr.h:81: undefined reference to `operator delete(void*, unsigned long)'
/usr/bin/ld: /home/dev/orwell/liborwell_rust/zlmediakit_rust/target/debug/build/zlmediakit_rust-499cc82f14515635/out/liblibzlmediakit_cpp_interface.a(interface.cpp.o): in function `__static_initialization_and_destruction_0(int, int)':
/usr/include/c++/9/iostream:74: undefined reference to `std::ios_base::Init::Init()'
/usr/bin/ld: /usr/include/c++/9/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
/usr/bin/ld: /home/dev/orwell/liborwell_rust/zlmediakit_rust/target/debug/build/zlmediakit_rust-499cc82f14515635/out/liblibzlmediakit_cpp_interface.a(interface.cpp.o):(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status
I've researched and found some answers (Link error "undefined reference to `__gxx_personality_v0'" and g++) that old me to link against libstdc++. As you see, I'm already doing that.
If I try to compile the CMake project alone, it links sucessfully. However then I compile everything from the Rust side, it gives this error.
Complete output of rust compilation

How do I use SFML with CMake FetchContent?

So I'd like to get the SFML from the git tag directly using CMake FetchContent. Most of the tutorial are not using this, so I don't really know what to do, I use imgui-sfml-fetchcontent for the reference.
My CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
include(FetchContent)
project(2DComputerGraphics)
set(CMAKE_CXX_STANDARD 17)
# SFML
set(SFML_VERSION "2.5.1")
FetchContent_Declare(
SFML
GIT_REPOSITORY "https://github.com/SFML/SFML.git"
GIT_TAG "${SFML_VERSION}"
)
FetchContent_GetProperties(SFML)
if(NOT SFML_POPULATED)
FetchContent_Populate(SFML)
add_subdirectory(${SFML_SOURCE_DIR} ${SFML_BINARY_DIR})
#
# message("SFML_SOURCE_DIR: ${SFML_SOURCE_DIR}")
# message("SFML_BINARY_DIR: ${SFML_BINARY_DIR}")
endif()
set(SOURCE
"main.cpp"
)
#
# message("Source: ${SOURCE}")
add_executable(2DComputerGraphicsApp
"${SOURCE}"
)
target_include_directories(2DComputerGraphicsApp PRIVATE
"${SFML_INCLUDE_DIR}"
)
#
# message("SFML_INCLUDE_DIR: ${SFML_INCLUDE_DIR}")
target_link_libraries(2DComputerGraphicsApp
"${SFML_LIBRARIES}"
"${SFML_DEPENDENCIES}"
)
#
# message("SFML_LIBRARIES: ${SFML_LIBRARIES}")
# message("SFML_DEPENDENCIES: ${SFML_DEPENDENCIES}")
target_compile_options(2DComputerGraphicsApp PRIVATE -Wall)
And it gives me this error
/usr/bin/ld: CMakeFiles/2DComputerGraphicsApp.dir/main.cpp.o: in function `main':
main.cpp:(.text+0x82): undefined reference to `sf::String::String(char const*, std::locale const&)'
/usr/bin/ld: main.cpp:(.text+0xa0): undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
/usr/bin/ld: main.cpp:(.text+0xd3): undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
/usr/bin/ld: main.cpp:(.text+0x100): undefined reference to `sf::Texture::Texture()'
/usr/bin/ld: main.cpp:(.text+0x119): undefined reference to `sf::Texture::create(unsigned int, unsigned int)'
/usr/bin/ld: main.cpp:(.text+0x132): undefined reference to `sf::Sprite::Sprite(sf::Texture const&)'
/usr/bin/ld: main.cpp:(.text+0x152): undefined reference to `sf::Window::isOpen() const'
/usr/bin/ld: main.cpp:(.text+0x173): undefined reference to `sf::Window::pollEvent(sf::Event&)'
/usr/bin/ld: main.cpp:(.text+0x190): undefined reference to `sf::Window::close()'
/usr/bin/ld: main.cpp:(.text+0x1da): undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
/usr/bin/ld: main.cpp:(.text+0x1f7): undefined reference to `sf::RenderTarget::clear(sf::Color const&)'
/usr/bin/ld: main.cpp:(.text+0x210): undefined reference to `sf::Texture::update(unsigned char const*)'
/usr/bin/ld: main.cpp:(.text+0x229): undefined reference to `sf::RenderStates::Default'
/usr/bin/ld: main.cpp:(.text+0x234): undefined reference to `sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'
/usr/bin/ld: main.cpp:(.text+0x243): undefined reference to `sf::Window::display()'
/usr/bin/ld: main.cpp:(.text+0x284): undefined reference to `sf::Texture::~Texture()'
/usr/bin/ld: main.cpp:(.text+0x293): undefined reference to `sf::RenderWindow::~RenderWindow()'
/usr/bin/ld: main.cpp:(.text+0x2fd): undefined reference to `sf::Texture::~Texture()'
/usr/bin/ld: main.cpp:(.text+0x311): undefined reference to `sf::RenderWindow::~RenderWindow()'
/usr/bin/ld: CMakeFiles/2DComputerGraphicsApp.dir/main.cpp.o: in function `sf::Sprite::~Sprite()':
main.cpp:(.text._ZN2sf6SpriteD2Ev[_ZN2sf6SpriteD5Ev]+0xf): undefined reference to `vtable for sf::Sprite'
/usr/bin/ld: main.cpp:(.text._ZN2sf6SpriteD2Ev[_ZN2sf6SpriteD5Ev]+0x1d): undefined reference to `vtable for sf::Sprite'
/usr/bin/ld: main.cpp:(.text._ZN2sf6SpriteD2Ev[_ZN2sf6SpriteD5Ev]+0x35): undefined reference to `sf::Transformable::~Transformable()'
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/2DComputerGraphicsApp.dir/build.make:84: 2DComputerGraphicsApp] Error 1
make[3]: Leaving directory '/home/andraantariksa/Projects/2d-computer-graphics/build'
make[2]: *** [CMakeFiles/Makefile2:216: CMakeFiles/2DComputerGraphicsApp.dir/all] Error 2
make[2]: Leaving directory '/home/andraantariksa/Projects/2d-computer-graphics/build'
make[1]: *** [Makefile:130: all] Error 2
make[1]: Leaving directory '/home/andraantariksa/Projects/2d-computer-graphics/build'
make: *** [Makefile:2: build] Error 2
I think it happen because I did not link the SFML correctly. How do I solve this?
The variables are wrong. https://cmake.org/cmake/help/v3.16/module/FetchContent.html states that <name> has to be lower case. Also squareskittles is right, you shouldn't use ${SFML_LIBRARIES} / ${SFML_INCLUDE_DIR}, this is only valid if the old FindSFML.cmake is used.
cmake_minimum_required(VERSION 3.10)
include(FetchContent)
project(2DComputerGraphics)
set(CMAKE_CXX_STANDARD 17)
set(SFML_VERSION "2.5.1")
FetchContent_Declare(
sfml
GIT_REPOSITORY "https://github.com/SFML/SFML.git"
GIT_TAG "${SFML_VERSION}"
)
FetchContent_GetProperties(sfml)
if(NOT sfml_POPULATED)
FetchContent_Populate(sfml)
add_subdirectory(${sfml_SOURCE_DIR} ${sfml_BINARY_DIR})
endif()
set(SOURCE
main.cpp
)
add_executable(2DComputerGraphicsApp
${SOURCE}
)
target_link_libraries(2DComputerGraphicsApp
PRIVATE
sfml-audio
sfml-graphics
sfml-system
sfml-window
)
target_compile_options(2DComputerGraphicsApp PRIVATE -Wall)

xml2 related "undefiened reference to...." errors in compiling "libaiml-0.6"

I have installed sudo apt-get install libxml2-dev but I don't know why do I get these error message when I want to make the libaiml AIML interpreter:
make all-recursive
make[1]: Entering directory '/home/m/libaiml'
Making all in src
make[2]: Entering directory '/home/m/libaiml/src'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/m/libaiml/src'
Making all in test_app
make[2]: Entering directory '/home/m/libaiml/test_app'
Making all in aiml
make[3]: Entering directory '/home/m/libaiml/test_app/aiml'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/m/libaiml/test_app/aiml'
make[3]: Entering directory '/home/m/libaiml/test_app'
/bin/bash ../libtool --tag=CXX --mode=link g++ -Wall -Werror -ansi -pedantic `xml2-config --cflags` -g -O2 -o test_app `xml2-config --libs` main.o ../src/libaiml.a -lstd_utils
g++ -Wall -Werror -ansi -pedantic -I/usr/include/libxml2 -g -O2 -o test_app main.o -lxml2 ../src/libaiml.a -lstd_utils
../src/libaiml.a(user_manager.o): In function `aiml::cUserManager::cUserManager(aiml::cCore&)':
/home/m/libaiml/src/user_manager.cpp:32: undefined reference to `xmlNewParserCtxt'
../src/libaiml.a(user_manager.o): In function `aiml::cUserManager::~cUserManager()':
/home/m/libaiml/src/user_manager.cpp:36: undefined reference to `xmlFreeParserCtxt'
../src/libaiml.a(user_manager.o): In function `aiml::cUserManager::save(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/m/libaiml/src/user_manager.cpp:101: undefined reference to `xmlNewTextWriterFilename'
/home/m/libaiml/src/user_manager.cpp:104: undefined reference to `xmlTextWriterSetIndent'
/home/m/libaiml/src/user_manager.cpp:105: undefined reference to `xmlTextWriterSetIndentString'
/home/m/libaiml/src/user_manager.cpp:108: undefined reference to `xmlTextWriterStartDocument'
/home/m/libaiml/src/user_manager.cpp:109: undefined reference to `xmlTextWriterStartElement'
/home/m/libaiml/src/user_manager.cpp:113: undefined reference to `xmlTextWriterStartElement'
/home/m/libaiml/src/user_manager.cpp:114: undefined reference to `xmlTextWriterWriteAttribute'
/home/m/libaiml/src/user_manager.cpp:118: undefined reference to `xmlTextWriterStartElement'
/home/m/libaiml/src/user_manager.cpp:119: undefined reference to `xmlTextWriterWriteAttribute'
/home/m/libaiml/src/user_manager.cpp:120: undefined reference to `xmlTextWriterWriteCDATA'
/home/m/libaiml/src/user_manager.cpp:121: undefined reference to `xmlTextWriterEndElement'
/home/m/libaiml/src/user_manager.cpp:123: undefined reference to `xmlTextWriterEndElement'
/home/m/libaiml/src/user_manager.cpp:126: undefined reference to `xmlTextWriterEndElement'
/home/m/libaiml/src/user_manager.cpp:127: undefined reference to `xmlTextWriterEndDocument'
/home/m/libaiml/src/user_manager.cpp:138: undefined reference to `xmlFreeTextWriter'
../src/libaiml.a(user_manager.o): In function `aiml::cUserManager::load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/m/libaiml/src/user_manager.cpp:51: undefined reference to `xmlCtxtReadFile'
/home/m/libaiml/src/user_manager.cpp:55: undefined reference to `xmlDocGetRootElement'
/home/m/libaiml/src/user_manager.cpp:93: undefined reference to `xmlFreeDoc'
../src/libaiml.a(config_parser.o): In function `aiml::cConfigParser::cConfigParser(aiml::cCore&)':
/home/m/libaiml/src/config_parser.cpp:38: undefined reference to `xmlNewParserCtxt'
../src/libaiml.a(config_parser.o): In function `aiml::cConfigParser::~cConfigParser()':
/home/m/libaiml/src/config_parser.cpp:42: undefined reference to `xmlFreeParserCtxt'
../src/libaiml.a(config_parser.o): In function `aiml::cConfigParser::load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)':
/home/m/libaiml/src/config_parser.cpp:51: undefined reference to `xmlCtxtReadFile'
/home/m/libaiml/src/config_parser.cpp:55: undefined reference to `xmlDocGetRootElement'
/home/m/libaiml/src/config_parser.cpp:78: undefined reference to `xmlFreeDoc'
../src/libaiml.a(aiml_parser.o): In function `aiml::AIMLparser::onError()':
/home/m/libaiml/src/aiml_parser.cpp:120: undefined reference to `xmlCtxtGetLastError'
/home/m/libaiml/src/aiml_parser.cpp:120: undefined reference to `xmlCtxtGetLastError'
/home/m/libaiml/src/aiml_parser.cpp:124: undefined reference to `xmlStopParser'
../src/libaiml.a(aiml_parser.o): In function `aiml::AIMLparser::onFatalError()':
/home/m/libaiml/src/aiml_parser.cpp:130: undefined reference to `xmlCtxtGetLastError'
/home/m/libaiml/src/aiml_parser.cpp:130: undefined reference to `xmlCtxtGetLastError'
/home/m/libaiml/src/aiml_parser.cpp:134: undefined reference to `xmlStopParser'
../src/libaiml.a(aiml_parser.o): In function `aiml::AIMLparser::startElement(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::list<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)':
/home/m/libaiml/src/aiml_parser.cpp:211: undefined reference to `xmlStopParser'
/home/m/libaiml/src/aiml_parser.cpp:296: undefined reference to `xmlStopParser'
/home/m/libaiml/src/aiml_parser.cpp:337: undefined reference to `xmlStopParser'
../src/libaiml.a(aiml_parser.o): In function `aiml::AIMLparser::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, bool)':
/home/m/libaiml/src/aiml_parser.cpp:88: undefined reference to `xmlCreateFileParserCtxt'
/home/m/libaiml/src/aiml_parser.cpp:94: undefined reference to `xmlParseDocument'
/home/m/libaiml/src/aiml_parser.cpp:102: undefined reference to `xmlFreeDoc'
/home/m/libaiml/src/aiml_parser.cpp:103: undefined reference to `xmlFreeParserCtxt'
collect2: error: ld returned 1 exit status
Makefile:225: recipe for target 'test_app' failed
make[3]: *** [test_app] Error 1
make[3]: Leaving directory '/home/m/libaiml/test_app'
Makefile:274: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/m/libaiml/test_app'
Makefile:250: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/m/libaiml'
Makefile:179: recipe for target 'all' failed
make: *** [all] Error 2

CGAL compile error

I installed all the required libraries of CGAL, and added all the library path to my makefile while compiling my program on linux, but it still occured compiling error.
This is the content of my makefile
//--------------------------------------------------
FLAGS = -Wall -g -std=c++11 -O3
BOOST_LIB_PATH = -I /usr/include/include/
CGAL_LIB_PATH = -I /usr/local/include/
all :
g++ $(FLAGS) $(BOOST) $(CGAL) main.cpp -o main
clean :
rm main
//--------------------------------------------------
Bellow is the error message while compiling, Please help !
//----------------------------------------------------
g++ -Wall -g -std=c++11 -O3 -I /usr/include/include/ -I /usr/local/include/ main.cpp -o main
/usr/local/include/CGAL/Interval_nt.h:208: undefined reference to `CGAL::assertion_fail(char const*, char const*, int, char const*)'
/usr/local/include/CGAL/Interval_nt.h:210: undefined reference to `CGAL::assertion_fail(char const*, char const*, int, char const*)'
/tmp/cc5WX5dM.o: In function `~Gmpz_rep':
/usr/local/include/CGAL/GMP/Gmpz_type.h:57: undefined reference to `__gmpz_clear'
/usr/local/include/CGAL/GMP/Gmpz_type.h:57: undefined reference to `__gmpz_clear'
/usr/local/include/CGAL/GMP/Gmpz_type.h:57: undefined reference to `__gmpz_clear'
/tmp/cc5WX5dM.o: In function `CGAL::Gmpz::operator==(CGAL::Gmpz const&) const':
/usr/local/include/CGAL/GMP/Gmpz_type.h:154: undefined reference to `__gmpz_cmp'
/usr/local/include/CGAL/GMP/Gmpz_type.h:154: undefined reference to `__gmpz_cmp'
/tmp/cc5WX5dM.o: In function `CGAL::Quadratic_program_solution<CGAL::Gmpz>::optimality_certificate_numerators_begin() const':
/usr/local/include/CGAL/QP_solution.h:460: undefined reference to `CGAL::assertion_fail(char const*, char const*, int, char const*)'
/tmp/cc5WX5dM.o: In function `CGAL::Gmpz::operator<(CGAL::Gmpz const&) const':
/usr/local/include/CGAL/GMP/Gmpz_type.h:152: undefined reference to `__gmpz_cmp'
/usr/local/include/CGAL/GMP/Gmpz_type.h:152: undefined reference to `__gmpz_cmp'
/usr/local/include/CGAL/GMP/Gmpz_type.h:152: undefined reference to `__gmpz_cmp'
/tmCGAL::assertion_fail(char const*, char const*, int, char const*)'
collect2: error: ld returned 1 exit status
make: *** [all] Error 1
I had a similar problem. I fix it by adding
find_library( GMP_LIB NAMES "gmp" PATHS ${CMAKE_LIBRARY_PATH} )
and add it to the target_link_libraries

Qt5 cmake cannot find header file of ui

I'm creating a cmake project of my Qt5 application. Now when I compile my application using cmake in Clion I got a fatal error.
My CMakeLists.txt file looks like:
cmake_minimum_required(VERSION 2.8.11)
project(Oefening11_kv)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set (CMAKE_PREFIX_PATH C:\\Qt\\Qt5.8.0\\5.8\\mingw53_32\\lib\\cmake\\)
# Find the Qt libraries
find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets)
find_package(Qt5Gui)
find_package(Qt5Charts)
set(Oefening11_kv_SOURCES main.cpp oefening11a.cpp oefening11b.cpp oefening11c.cpp)
set(Oefening11_kv_HEADERS oefening11a.h oefening11b.h oefening11c.h)
set(Oefening11_kv_FORMS oefening11a.ui)
QT5_WRAP_CPP(Oefening11_kv_HEADERS_MOC ${Oefening11_kv_HEADERS})
QT5_WRAP_UI(Oefening11_kv_FORMS_HEADERS ${Oefening11_kv_FORMS})
add_library(Oefening11_kv_CONFIG ${Oefening11_kv_HEADERS_MOC} ${Oefening11_kv_FORMS_HEADERS})
QT5_USE_MODULES(Oefening11_kv_CONFIG Widgets)
add_executable(Oefening11_kv ${Oefening11_kv_SOURCES} ${Oefening11_kv_CONFIG})
QT5_USE_MODULES(Oefening11_kv Core Gui Widgets Charts)
The error that Clion is trowing when I compile the application is:
oefening11a.cpp:21: undefined reference to
__imp__ZN8QtCharts11QLineSeriesC1EP7QObject' oefening11a.cpp:26:
undefined reference to__imp__ZN8QtCharts9QXYSeries6appendEdd'
oefening11a.cpp:30: undefined reference to
__imp__ZN8QtCharts6QChartC1EP13QGraphicsItem6QFlagsIN2Qt10WindowTypeEE' oefening11a.cpp:31: undefined reference to
__imp__ZN8QtCharts6QChart9addSeriesEPNS_15QAbstractSeriesE'
oefening11a.cpp:32: undefined reference to
__imp__ZNK8QtCharts6QChart6legendEv' oefening11a.cpp:33: undefined
reference to__imp__ZN8QtCharts6QChart8setTitleERK7QString'
oefening11a.cpp:36: undefined reference to
__imp__ZN8QtCharts10QValueAxisC1EP7QObject' oefening11a.cpp:37:
undefined reference to
__imp__ZN8QtCharts10QValueAxis14setLabelFormatERK7QString'
oefening11a.cpp:38: undefined reference to
__imp__ZN8QtCharts13QAbstractAxis12setTitleTextERK7QString'
oefening11a.cpp:39: undefined reference to
__imp__ZN8QtCharts6QChart7addAxisEPNS_13QAbstractAxisE6QFlagsIN2Qt13AlignmentFlagEE'
oefening11a.cpp:40: undefined reference to
__imp__ZN8QtCharts15QAbstractSeries10attachAxisEPNS_13QAbstractAxisE'
oefening11a.cpp:43: undefined reference to
__imp__ZN8QtCharts10QValueAxisC1EP7QObject' oefening11a.cpp:44:
undefined reference to
__imp__ZN8QtCharts10QValueAxis14setLabelFormatERK7QString'
oefening11a.cpp:45: undefined reference to
__imp__ZN8QtCharts13QAbstractAxis12setTitleTextERK7QString'
oefening11a.cpp:46: undefined reference to
__imp__ZN8QtCharts6QChart7addAxisEPNS_13QAbstractAxisE6QFlagsIN2Qt13AlignmentFlagEE'
oefening11a.cpp:47: undefined reference to
__imp__ZN8QtCharts15QAbstractSeries10attachAxisEPNS_13QAbstractAxisE'
oefening11a.cpp:50: undefined reference to
__imp__ZN8QtCharts10QChartViewC1EPNS_6QChartEP7QWidget'
oefening11a.cpp:51: undefined reference to
__imp__ZN13QGraphicsView13setRenderHintEN8QPainter10RenderHintEb'
oefening11a.cpp:54: undefined reference to
__imp__ZN11QMainWindow16setCentralWidgetEP7QWidget'
oefening11a.cpp:73: undefined reference to
__imp__ZN10QStatusBar11showMessageERK7QStringi' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x38):
undefined reference to QMainWindow::event(QEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x40):
undefined reference toQObject::eventFilter(QObject*, QEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x48):
undefined reference to QObject::timerEvent(QTimerEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x50):
undefined reference toQObject::childEvent(QChildEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x58):
undefined reference to QObject::customEvent(QEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x60):
undefined reference toQObject::connectNotify(QMetaMethod const&)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x68):
undefined reference to QObject::disconnectNotify(QMetaMethod const&)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x70):
undefined reference toQWidget::devType() const'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x78):
undefined reference to QWidget::setVisible(bool)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x80):
undefined reference toQWidget::sizeHint() const'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x88):
undefined reference to QWidget::minimumSizeHint() const'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x90):
undefined reference toQWidget::heightForWidth(int) const'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x98):
undefined reference to QWidget::hasHeightForWidth() const'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xa0):
undefined reference toQWidget::paintEngine() const'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xa8):
undefined reference to QWidget::mousePressEvent(QMouseEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xb0):
undefined reference toQWidget::mouseReleaseEvent(QMouseEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xb8):
undefined reference to QWidget::mouseDoubleClickEvent(QMouseEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xc0):
undefined reference toQWidget::mouseMoveEvent(QMouseEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xc8):
undefined reference to QWidget::wheelEvent(QWheelEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xd0):
undefined reference toQWidget::keyPressEvent(QKeyEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xd8):
undefined reference to QWidget::keyReleaseEvent(QKeyEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xe0):
undefined reference toQWidget::focusInEvent(QFocusEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xe8):
undefined reference to QWidget::focusOutEvent(QFocusEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xf0):
undefined reference toQWidget::enterEvent(QEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xf8):
undefined reference to QWidget::leaveEvent(QEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x100):
undefined reference toQWidget::paintEvent(QPaintEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x108):
undefined reference to QWidget::moveEvent(QMoveEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x110):
undefined reference toQWidget::resizeEvent(QResizeEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x118):
undefined reference to QWidget::closeEvent(QCloseEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x120):
undefined reference to
QMainWindow::contextMenuEvent(QContextMenuEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x128):
undefined reference to QWidget::tabletEvent(QTabletEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x130):
undefined reference toQWidget::actionEvent(QActionEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x138):
undefined reference to QWidget::dragEnterEvent(QDragEnterEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x140):
undefined reference toQWidget::dragMoveEvent(QDragMoveEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x148):
undefined reference to QWidget::dragLeaveEvent(QDragLeaveEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x150):
undefined reference toQWidget::dropEvent(QDropEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x158):
undefined reference to QWidget::showEvent(QShowEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x160):
undefined reference toQWidget::hideEvent(QHideEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x168):
undefined reference to QWidget::nativeEvent(QByteArray const&, void*,
long*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x170):
undefined reference toQWidget::changeEvent(QEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x178):
undefined reference to
QWidget::metric(QPaintDevice::PaintDeviceMetric) const'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x180):
undefined reference toQWidget::initPainter(QPainter*) const'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x188):
undefined reference to QWidget::redirected(QPoint*) const'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x190):
undefined reference toQWidget::sharedPainter() const'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x198):
undefined reference to QWidget::inputMethodEvent(QInputMethodEvent*)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x1a0):
undefined reference to
QWidget::inputMethodQuery(Qt::InputMethodQuery) const'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x1a8):
undefined reference to QWidget::focusNextPrevChild(bool)'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x1b0):
undefined reference toQMainWindow::createPopupMenu()'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x1d8):
undefined reference to non-virtual thunk to QWidget::devType() const'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x1e0):
undefined reference tonon-virtual thunk to QWidget::paintEngine()
const'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x1e8):
undefined reference to non-virtual thunk to
QWidget::metric(QPaintDevice::PaintDeviceMetric) const'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x1f0):
undefined reference tonon-virtual thunk to
QWidget::initPainter(QPainter*) const'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x1f8):
undefined reference to non-virtual thunk to
QWidget::redirected(QPoint*) const'
t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x200):
undefined reference tonon-virtual thunk to QWidget::sharedPainter()
const'
Can't find the problem in my cmake file. Can someone help me with this?
Ok I found the issue. I was using a x64 compiler on x86 QT5 libraries. When changing the compiler to a x86 one it compiles.
Besides moc, you will need to run uic as well:
set(CMAKE_AUTOUIC ON)