views:

37

answers:

1

HI, 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, same program I'm able to compile with normal VS2008 solution which is not created with CMake.

Following is cmakelists.txt file content

//////////////////////////////////////////////

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.

Thanks.

A: 

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.

Jack Kelly
It worked for me. Thanks a lot.
harik