cmake for Visual Studio and link errors

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
AndrzejB
Earned some good credits
Earned some good credits
Posts: 105
Joined: Sun Nov 29, 2015 12:46 pm

cmake for Visual Studio and link errors

Post by AndrzejB »

1. Download wxWidgets 3.1.5 sources for Windows
2. Install to c:\wxWidgets-3.1.5
3. In Visual Studio Powershell in directory C:\wxWidgets-3.1.5\build\msw make:
nmake -f makefile.vc UNICODE=1 BUILD=release TARGET_CPU=X64
4. Go to project C:\gitmy\scintas\src\build and cmake -G "Visual Studio 16 2019" ..
Are link errors

Code: Select all

C:\wxWidgets-3.1.5\lib\vc_x64_lib\wxbase31ud.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
C:\wxWidgets-3.1.5\lib\vc_x64_lib\wxmsw31ud_stc.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
C:\wxWidgets-3.1.5\lib\vc_x64_lib\wxbase31ud_net.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'
My CMakeLists.txt is

Code: Select all

cmake_minimum_required(VERSION 3.7)
project(scintas)

set(CMAKE_CXX_STANDARD 14)

if(UNIX)
set(wxWidgets_ROOT_DIR /usr/include/wx-3.1)
elseif(WIN32)
set(wxWidgets_ROOT_DIR c:/wxWidgets-3.1.5)
    set(wxWidgets_LIB_DIR ${wxWidgets_ROOT_DIR}/lib/vc_x64_lib)
    if(CMAKE_BUILD_TYPE STREQUAL "Debug")
        set(wxWidgets_CONFIGURATION vc_mswud_x64)
    endif()
    if(CMAKE_BUILD_TYPE STREQUAL "Release")
        set(wxWidgets_CONFIGURATION vc_mswu_x64)
    endif()
endif()
find_package(wxWidgets COMPONENTS core base stc net REQUIRED)
include("${wxWidgets_USE_FILE}")
message(STATUS "foo include dir: ${wxWidgets_LIBRARIES}")

set(SOURCE_FILES main.cpp Editor.cpp EditorFactory.cpp Config.cpp MessageBox/MessageBox.cpp
        IniParser/IniParser.cpp IniParser/StrTools.cpp execute.cpp
        MyTabArt.cpp
        IPC/MyServer.cpp IPC/CmdStruct.cpp
        IPC/MyClient.cpp IPC/MyConnectionClient.cpp
        IPC/MyConnectionServer.cpp
        ../3rdparty/auimod/framemanager.cpp
        ../3rdparty/auimod/auibook.cpp
        ../3rdparty/auimod/tabmdi.cpp
        ../3rdparty/auimod/tabart.cpp
        ../3rdparty/auimod/tabartmsw.cpp
        ../3rdparty/auimod/dockart.cpp
        ../3rdparty/auimod/floatpane.cpp
        ../3rdparty/auimod/auibar.cpp
        )
add_executable(scintas ${SOURCE_FILES})

if(CMAKE_COMPILER_IS_GNUCXX)
SET(GCC_COVERAGE_COMPILE_FLAGS "-Werror=return-type")
add_definitions(${GCC_COVERAGE_COMPILE_FLAGS})
else()
add_definitions(-DUSE64bit=true)
endif()
add_definitions(-DwxUSE_UNICODE=1)

target_include_directories(scintas
        PRIVATE
        ../3rdparty/cpp-ipc/include
        )

target_link_directories(scintas
        PRIVATE
        ../3rdparty
        )

target_link_libraries(scintas ${wxWidgets_LIBRARIES})
and my project: https://github.com/ideorg/scintas
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4182
Joined: Sun Jan 03, 2010 5:45 pm

Re: cmake for Visual Studio and link errors

Post by PB »

I wonder if TARGET_CPU=X64 really works with nmake - it appears it does not for you. I always run 64-bit MSVS command prompt without using TARGET_CPU to build 64-bit.
Post Reply