linker error using wxwidgets with cmake

可紊 提交于 2019-12-14 03:59:03

问题


I'm getting following linker error when I compile my program with VS2008 solution which is created with CMake for my wxwidgets based application.

error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup

but I'm able to compile the same program with a normal VS2008 solution which is not created with CMake.

cmakelists.txt file contents:

cmake_minimum_required(VERSION 2.8)

SET(CMAKE_DEBUG_POSTFIX "d")

ADD_DEFINITIONS(-DOSG_DEBUG_POSTFIX="${CMAKE_DEBUG_POSTFIX}")

SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)

SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)

SET(ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

SET(RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

set(BOOST_ROOT "E:/boost_1_38_0") 

FIND_PACKAGE( Boost 1.38.0 REQUIRED unit_test_framework )

SET(wxWidgets_ROOT_DIR "E:/wxWidgets-2.9.0")

find_package(wxWidgets COMPONENTS aui html adv core xml base REQUIRED)

INCLUDE(${wxWidgets_USE_FILE})

ADD_EXECUTABLE(browser
BrowserApp.cpp
BrowserApp.h
BrowserMain.cpp
BrowserMain.h
)

TARGET_LINK_LIBRARIES(browser
common
${wxWidgets_LIBRARIES}
)

I'm trying to make my application run across platforms using CMake build system.

Any help is appreciated.


回答1:


Do you need to make it a Win32 executable by using the following add_executable line?

add_executable(browser WIN32 BrowserApp.cpp BrowserApp.h BrowserMain.cpp BrowserMain.h)

Also, if you're using a reasonably recent CMake, you don't have to use ALL_CAPS_EVERYWHERE anymore.



来源:https://stackoverflow.com/questions/3747099/linker-error-using-wxwidgets-with-cmake

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!