0

I am trying to make a library using keystone and I was getting a lot of errors while using Cmake which was not happening when I use make. The CMakeLists.txt that I used was

cmake_minimum_required(VERSION 2.8)
project(sample)
set(CMAKE_C_FLAGS "-lstdc++ -lm")
include_directories("../../include")
add_executable(sample sample.c)
target_link_libraries(sample keystone)

The Makefile that worked perfectly was

.PHONY: all clean
KEYSTONE_LDFLAGS = -lkeystone -lstdc++ -lm
all:
    gcc -o sample sample.c ${KEYSTONE_LDFLAGS}
clean:
    rm -rf *.o sample

The sample.c file that I used is here

The error that I get is here.

What changes should I make so that the Cmake works fine.

  • To add to @Tsyvarev comment: you;d probably need to pass full path to `keystone` library. – arrowd Aug 29 '17 at 18:21
  • Bottom line: Don't do this! Translating Makefiles to CMake code is not straightforward, as both systems rely on vastly different idioms and assumptions. Also, remember that CMake is supposed to be a portable description of the build, so unconditionally adding toolchain-specific compile flags like `-lstdc++` is a recipe for trouble. – ComicSansMS Aug 30 '17 at 12:16

0 Answers0