GCC: Skipping incompatible (ERROR)

Good morning,

I switched my IDE and applied the required additional include & preprocessor definitions into the CMakeLists.txt file, but encounter errors when trying to BUILD the project (x86 / Release).

The binary consists of multiple .cpp files and should be linked with the STATIC curl library(x86), which is installed in the /dependencies/curl directory.

CMakeLists.txt:

cmake_minimum_required(VERSION 3.24.0)
project(recorder)

set(CMAKE_CXX_STANDARD 20)
set (CMAKE_CXX_FLAGS "-fpermissive -m32")

# Set flags to build 32-bit binary & which exe to use for C / C++
set(CMAKE_C_COMPILER gcc)
set(CMAKE_C_FLAGS -m32)
set(CMAKE_CXX_COMPILER g++)

# Define project
file(GLOB_RECURSE MY_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
add_executable(${PROJECT_NAME} "${MY_SOURCES}")

# Preprocessor definitions
target_compile_definitions(${PROJECT_NAME} PUBLIC WIN32 NDEBUG _CONSOLE CURL_STATICLIB UNICODE _UNICODE)

# Include directories
include_directories(${PROJECT_NAME}
    PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
    PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/curl/include")

# Add libcurl library
add_library(curl STATIC "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/curl/lib/libcurl_a.lib")
set_target_properties(curl PROPERTIES LINKER_LANGUAGE C)

# Link project with library
target_link_libraries(${PROJECT_NAME} PUBLIC curl)

Errors Screenshot

My new IDE build settings

The library is for x86 & Release and I have specified the flags inside the cmake file to match it, but I still receive incompatibility errors, why is that?

It looks to me like the error is specifically coming from the duplicate const in the signature for get_full_name and get_long_name. Should the second const come after the pointer?

1 Like

Thanks for the response, I got past those errors, but now the errors display “skipping incompatible”.

Error Messages

It seems like the library definitions you currently have were compiled with gcc. It’s possible that your new IDE is currently set up to use a different compiler, which would explain why it’s saying “skipping incompatible.” Do you know which compiler your IDE is using?

EDIT: I see your cmake file manually sets the compiler. I wonder if its possible the IDE is overriding this. If not I’m unsure why it would skip those library definitions.

1 Like

This line seems off. Typically the way you link an external library is by first finding the files with find_package, then linking the target like target_link_libraries(${PROJECT_NAME} PRIVATE CURL::libcurl). For Curl specifically, there also seems to be an official FindCURL module.

My guess is that you’d need to write something along the lines of

include(FindCURL)
find_package(CURL REQUIRED)
if (CURL_FOUND)
  target_link_libraries(${PROJECT_NAME} PRIVATE CURL::libcurl)
else() 
  # fail with a useful message
endif()

I’ve never linked against curl though, so to some extent I’m just guesing based on the documentation.

It’s possible also, if you’re compiling curl yourself with CMake, that you may want to find Curl in a slightly different way using find_package(CURL CONFIG REQUIRED). This seems to be what this part of the FindCURL module documentation is suggesting. In which case you may also have to add to your prefix path. Something like

include(FindCURL)
list(APPEND CMAKE_PREFIX_PATH <path>/<to>/<directory-with-CURLConfig.cmake>)
find_package(CURL CONFIG REQUIRED)

Also note, that instead of

include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/curl/include)

you’d probably want to write

include_directories(${PROJECT_NAME} PUBLIC ${CURL_INCLUDE_DIRS})
1 Like

@Roberto Your messages are being flagged as spam due to the external links. Rather than linking to an external site hosting screenshots, please attach your image(s) directly to the post and you should avoid the posts being flagged (unless you post lots of images, which may also flag your post). It will also help people searching for things if you can copy-n-paste text as text rather than taking a screenshot of the text.

2 Likes

Thanks for the information, I will do that in the future!