Here is my main CmakeLists.txt:
cmake_minimum_required(VERSION 3.16)
project(Vibranium_Core)
set(CMAKE_CXX_STANDARD 14)
find_package(Boost 1.72.0)
if(NOT Boost_FOUND)
message(FATAL_ERROR "Could not find boost!")
endif()
include_directories(${Boost_INCLUDE_DIR})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Source/Common)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Source/Core/WorldServer)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Source/Core/AuthServer)
set_target_properties(
Common WorldServer AuthServer
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
Here is my: /Source/Common/CmakeLists.txt:`
add_library(Common SHARED Config.cpp Config.h Logger.cpp Logger.h)
target_include_directories(Common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
When I try to build my project I get:
NMAKE : fatal error U1073: don't know how to make 'bin\lib\Common.lib'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
I have this problem only on Windows. When I try to build the project on Linux there is no issue. What is causing this problem and how can I fix it?
Related
I'm wondering what is wrong with my configuration that prevents it from running the Boost test.
I have this make file:
cmake_minimum_required(VERSION 3.10)
project(Fubi)
set(BOOST_ROOT "C:/local/boost_1_73_0")
set(Boost_INCLUDE_DIRS "C:/local/boost_1_73_0")
set(Boost_LIBRARY_DIRS "C:/local/boost_1_73_0/lib64-msvc-14.2")
set(Boost_USE_STATIC_LIBS ON)
message(STATUS "BOOST_ROOT: ${BOOST_ROOT}")
message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost_LIBRARY_DIRS: ${Boost_LIBRARY_DIRS}")
find_package(Boost REQUIRED)
find_package(Boost REQUIRED COMPONENTS unit_test_framework)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
set(SOURCES DbgHelpDll.cpp Fubi.cpp SysExports.cpp fubimain.cpp stdafx.cpp)
add_executable(Fubi ${SOURCES})
target_link_libraries(Fubi PRIVATE DbgHelp)
set_property(TARGET Fubi PROPERTY ENTRY_POINT "fubimain.cpp")
set(CMAKE_GENERATOR_PLATFORM x86)
set(CMAKE_SYSTEM_VERSION 6.0)
set(TEST_SOURCES TestSignatureParser.cpp)
#add_definitions(-DBOOST_TEST_DYN_LINK)
add_definitions(-DBOOST_TEST_STATIC_LINK)
add_executable(tests ${TEST_SOURCES})
target_link_libraries(tests ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
message(STATUS "Compiler version: ${CMAKE_CXX_COMPILER_VERSION}")
Then trying to build the project with CLion:
====================[ Build | all | Debug ]=====================================
"C:\Program Files\JetBrains\CLion 2019.2.5\bin\cmake\win\bin\cmake.exe" --build C:\Users\cyberquarks\ClionProjects\fubi\cmake-build-debug --target all --
[ 75%] Built target Fubi
Scanning dependencies of target tests
[ 87%] Building CXX object CMakeFiles/tests.dir/TestSignatureParser.cpp.obj
TestSignatureParser.cpp
[100%] Linking CXX executable tests.exe
LINK Pass 1: command "C:\PROGRA~2\MIB055~1\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx86\x86\link.exe /nologo #CMakeFiles\tests.dir\objects1.rsp /out:tests.exe /implib:tests.lib /pdb:C:\Users\cyberquarks\ClionProjects\fubi\cmake-build-debug\tests.pdb /version:0.0 /machine:X86 /debug /INCREMENTAL /subsystem:console -LIBPATH:C:\local\boost_1_73_0\stage\lib C:\local\boost_1_73_0\stage\lib\libboost_unit_test_framework-vc142-mt-gd-x32-1_73.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\tests.dir/intermediate.manifest CMakeFiles\tests.dir/manifest.res" failed (exit code 1120) with the following output:
libboost_unit_test_framework-vc142-mt-gd-x32-1_73.lib(unit_test_main.obj) : error LNK2019: unresolved external symbol "class boost::unit_test::test_suite * __cdecl init_unit_test_suite(int,char * * const)" (?init_unit_test_suite##YAPAVtest_suite#unit_test#boost##HQAPAD#Z) referenced in function __catch$?unit_test_main#unit_test#boost##YAHP6APAVtest_suite#12#HQAPAD#ZH0#Z$4
tests.exe : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files\JetBrains\CLion 2019.2.5\bin\cmake\win\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
And here's the CMake log when the project was imported with the CLion IDEA (also during reloading):
"C:\Program Files\JetBrains\CLion 2019.2.5\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - NMake Makefiles" C:\Users\cyberquarks\ClionProjects\fubi
-- BOOST_ROOT: C:/local/boost_1_73_0
-- Boost_INCLUDE_DIRS: C:/local/boost_1_73_0
-- Boost_LIBRARY_DIRS: C:/local/boost_1_73_0/lib64-msvc-14.2
-- Found Boost: C:/local/boost_1_73_0 (found version "1.73.0")
CMake Warning at C:/Program Files/JetBrains/CLion 2019.2.5/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1144 (message):
New Boost version may have incorrect or missing dependencies and imported
targets
Call Stack (most recent call first):
C:/Program Files/JetBrains/CLion 2019.2.5/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1266 (_Boost_COMPONENT_DEPENDENCIES)
C:/Program Files/JetBrains/CLion 2019.2.5/bin/cmake/win/share/cmake-3.15/Modules/FindBoost.cmake:1904 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:21 (find_package)
-- Found Boost: C:/local/boost_1_73_0 (found version "1.73.0") found components: unit_test_framework
-- Compiler version: 19.29.30147.0
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/cyberquarks/ClionProjects/fubi/cmake-build-debug
[Finished]
Here's the test source:
/**
* #file TestSignatureParser.cpp
* #brief
*
* #author
* #date 2022-12-20
*/
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
//#include "SysExports.h"
// Create a test suite
BOOST_AUTO_TEST_SUITE(SignatureParserTestSuite)
// Define a test case for parsing a valid function signature
BOOST_AUTO_TEST_CASE(ParseValidSignature) {
}
// Define a test case for parsing an invalid function signature
BOOST_AUTO_TEST_CASE(ParseInvalidSignature) {
}
// End the test suite
BOOST_AUTO_TEST_SUITE_END()
You've specified BOOST_TEST_NO_MAIN and then not implemented your own main, use BOOST_TEST_MODULE instead.
So, I have no code, just empty files and a CMake, but I keep getting that Linker Error. Can someone please explain in a lot of detail what my problem is? Some info I have is that I am supposed to be using Visual Studio 2015 as my compiler and stuff, which I think I already have set up.
The Error:
[100%] Linking CXX executable Debug\CinderGame\CinderGame.exe
NMAKE : fatal error U1077: '"C:\Program Files\JetBrains\CLion 2020.2.3\bin\cmake\win\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
LINK Pass 1: command "C:\PROGRA~2\MICROS~1.0\VC\bin\link.exe /nologo #CMakeFiles\CinderGame.dir\objects1.rsp /out:Debug\CinderGame\CinderGame.exe /implib:CinderGame.lib /pdb:C:\Users\cesar\Documents\GitHub\final-project-cesarmonsalud\cmake-build-debug\Debug\CinderGame\CinderGame.pdb /version:0.0 /machine:X86 /debug /INCREMENTAL /subsystem:windows /NODEFAULTLIB:LIBCMT /NODEFAULTLIB:LIBCPMT -LIBPATH:C:\Users\cesar\Desktop\cinder_0.9.2_vc2015\lib\msw\x86 C:\Users\cesar\Desktop\cinder_0.9.2_vc2015\lib\msw\x86\Debug\v140\cinder.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\CinderGame.dir/intermediate.manifest CMakeFiles\CinderGame.dir/manifest.res" failed (exit code 1120) with the following output:
LIBCMTD.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _WinMain#16 referenced in function "int __cdecl invoke_main(void)" (?invoke_main##YAHXZ)
Debug\CinderGame\CinderGame.exe : fatal error LNK1120: 1 unresolved externals
The Code:
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 11)
project(Connect4)
# This tells the compiler to not aggressively optimize and
# to include debugging information so that the debugger
# can properly read what's going on.
set(CMAKE_BUILD_TYPE Debug)
# Let's ensure -std=c++xx instead of -std=g++xx
set(CMAKE_CXX_EXTENSIONS OFF)
# Let's nicely support folders in IDE's
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Warning flags
if(MSVC)
# warning level 3 and all warnings as errors
add_compile_options(/W3)
else()
# lots of warnings and all warnings as errors
add_compile_options(-Wall -Wpedantic -Werror)
endif()
# FetchContent added in CMake 3.11, downloads during the configure step
include(FetchContent)
# FetchContent_MakeAvailable was not added until CMake 3.14
if(${CMAKE_VERSION} VERSION_LESS 3.14)
include(cmake/add_FetchContent_MakeAvailable.cmake)
endif()
FetchContent_Declare(
catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG devel
)
# Adds Catch2 testing library
FetchContent_GetProperties(catch2)
if(NOT catch2_POPULATED)
FetchContent_Populate(catch2)
add_library(catch2 INTERFACE )
target_include_directories(catch2 INTERFACE ${catch2_SOURCE_DIR}/single_include)
endif()
get_filename_component(CINDER_PATH "C:/Users/cesar/Desktop/cinder_0.9.2_vc2015" ABSOLUTE)
get_filename_component(APP_PATH "${CMAKE_CURRENT_SOURCE_DIR}/" ABSOLUTE)
include("${CINDER_PATH}/proj/cmake/modules/cinderMakeApp.cmake")
list(APPEND CORE_SOURCE_FILES
)
list(APPEND SOURCE_FILES ${CORE_SOURCE_FILES}
include/core/Connect4.h
include/visualizer/FinalProjectApp.h
src/core/Connect4.cpp
src/visualizer/FinalProjectApp.cpp
)
list(APPEND TEST_FILES tests/Connect4Tests.cpp)
ci_make_app(
APP_NAME CinderGame
CINDER_PATH ${CINDER_PATH}
SOURCES apps/cinder_game.cpp ${SOURCE_FILES}
INCLUDES include
)
ci_make_app(
APP_NAME ConsoleGame
CINDER_PATH ${CINDER_PATH}
SOURCES apps/main_console_game.cpp ${SOURCE_FILES}
INCLUDES include
)
ci_make_app(
APP_NAME GameTest
CINDER_PATH ${CINDER_PATH}
SOURCES tests/Connect4Tests.cpp ${SOURCE_FILES} ${TEST_FILES}
INCLUDES include
LIBRARIES catch2
)
if(MSVC)
set_property(TARGET GameTest APPEND_STRING PROPERTY LINK_FLAGS " /SUBSYSTEM:CONSOLE")
endif()
The culprit is probably:
if(MSVC)
set_property(TARGET GameTest APPEND_STRING PROPERTY LINK_FLAGS " /SUBSYSTEM:CONSOLE")
endif()
This tells the linker to build for a console subsystem, which does not have an implicit WinMain function: you'd have to write one yourself if you need a console build.
If you don't need a console build, you can change it to /SUBSYSTEM:WINDOWS and a WinMain will be supplied by MFC.
I am trying to set up a cross platform project.
In Windows I have installed package SDL2 with MSYS2 for x86 and x64.
In my CMakeLists.txt I have:
find_package(PkgConfig REQUIRED)
pkg_search_module(SDL2
REQUIRED sdl2 sdl
IMPORTED_TARGET)
if(TARGET PkgConfig::SDL2)
message(STATUS "Found SDL2")
endif()
Package seems to be found both for MinGW and MSVC.
Simple program compiles with MinGW
#include <SDL/SDL.h>
#undef main
int main()
{
return 0;
}
However with MSVC SDL header can't be found and the program does not compile.
C:\dev\repos\UWCASdk\Sandbox\JoySDL\joyTest.cpp(2): fatal error C1083: Cannot open include file: 'SDL/SDL.h': No such file or directory
NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1426~1.288\bin\Hostx86\x64\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX86\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX86\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX86\x64\nmake.exe"' : return code '0x2'
Stop.
Is it not possible to use PkgConfig with MSVC? Or should I use another package manager?
I have a problem while I am writing the cmake file. I have a project which both uses the Qt and WinSock2. But when I add set(CMAKE_AUTOMOC ON) to the CMake code, it gives me these errors:
Error 4 error C2011: 'sockaddr' : 'struct' type
redefinition C:\Program Files (x86)\Microsoft
SDKs\Windows\v7.0A\include\ws2def.h 212 Error 5 error C2059: syntax
error : 'constant' C:\Program Files (x86)\Microsoft
SDKs\Windows\v7.0A\include\ws2def.h 390 Error 6 error C3805:
'constant': unexpected token, expected either '}' or a ',' C:\Program
Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ws2def.h 390 ...
And my cmake file is as follows:
PROJECT(RFIDVis-core)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0 FATAL_ERROR)
#INCLUDE(../cmake/commonconf.cmake)
set(CMAKE_AUTOMOC ON)
#set(CMAKE_INCLUDE_CURRENT_DIR ON)
MESSAGE(STATUS "Configuring RFIDVis Source")
# glob sources from core directories
FILE(GLOB RFIDVisSources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
BusinessLogic/*.cpp
DataLayer/*.cpp
IrrlichtComponents/*.cpp
GeneratedFiles/Debug/*.cpp
Libraries/*.cpp
Presentation/*.cpp
main.cpp
)
FILE(GLOB RFIDVisHeaders RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
BusinessLogic/*.h
DataLayer/*.h
Libraries/*.h
Libraries/*.hpp
IrrlichtComponents/*.h
Presentation/*.h
)
FILE(GLOB CampvisApplicationForms
Presentation/*.ui
)
SET(RFIDVisApplicationToBeMocced
GeneratedFiles/ui_demomainwindow.h
)
#
# Qt related stuff:
#
QT5_WRAP_CPP(RFIDVisApplicationMoc ${RFIDVisApplicationToBeMocced})
LIST(APPEND RFIDVisApplicationSources ${RFIDVisApplicationMoc})
QT5_WRAP_UI(RFIDVisApplicationFormsHeaders ${RFIDVisApplicationForms})
LIST(APPEND RFIDVisApplicationSources ${RFIDVisApplicationFormsHeaders})
LINK_DIRECTORIES(${RFIDVisGlobalLinkDirectories} ${IRRLICHT_LIBRARY}
${RFIDVisHome}/ext/VISA/lib/msc/visa32.lib
${RFIDVisHome}/ext/VISA/lib/msc/rsspecan.lib
)
qt5_generate_moc(main.cpp main.moc)
ADD_EXECUTABLE(RFIDVis-application
${RFIDVisSources} ${RFIDVisHeaders} ${RFIDVisMocs}
)
ADD_DEFINITIONS(${RFIDVisGlobalDefinitions})
INCLUDE_DIRECTORIES(${RFIDVisGlobalIncludeDirs})
cmake_policy(SET CMP0020 NEW)
TARGET_LINK_LIBRARIES(RFIDVis-application Qt5::Core Qt5::Widgets ws2_32.lib
${RFIDVisHome}/ext/VISA/lib/msc/visa32.lib
${RFIDVisHome}/ext/VISA/lib/msc/rsspecan.lib
${IRRLICHT_LIBRARY})
qt5_use_modules(RFIDVis-application Core GUI Widgets)
DEFINE_SOURCE_GROUPS_FROM_SUBDIR(RFIDVisSources ${RFIDVisHome} "")
DEFINE_SOURCE_GROUPS_FROM_SUBDIR(RFIDVisHeaders ${RFIDVisHome} "")
The problem is that the windows.h is going to be added to the project after adding the AUTOMOC. So, the solution is to add add_definitions(-DWIN32_LEAN_AND_MEAN) to the cmake file. Then, the windows.h will not include the winsock and you can include it by yourself in your project
I'm trying to setup FLTK to build on windows with CMake with the Windows SDK.
So far here's what I've accomplished so far:
> svn co http://svn.easysw.com/public/fltk/fltk/branches/branch-1.3/ fltk-1.3
> cmake CMakeLists.txt -DOPTION_BUILD_EXAMPLES=NO -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=C:\dev\fltk-1.3
> nmake
> nmake install
No errors so far.
Then I created a test.cpp file with a hello world example I got off the documentation.
Here's my CMakeLists.txt:
cmake_minimum_required(VERSION 2.6)
project(Test)
find_package(FLTK REQUIRED NO_MODULE)
include(${FLTK_USE_FILE})
add_executable(test WIN32 test.cpp)
target_link_libraries(test fltk)
When I run cmake CMakeLists.txt I get an error asking me to set FLTK_DIR, so here's what I've got so far:
> cmake CMakeLists.txt
(error about FLTK_DIR)
> cmake CMakeLists.txt -DFLTK_DIR=C:\dev\fltk-1.3\CMake
> nmake
The last nmake command gives me this output:
[100%] Building CXX object CMakeFiles/test.dir/Test.cpp.obj
Test.cpp
Linking CXX executable test.exe
LINK : fatal error LNK1104: cannot open file ';.obj'
LINK Pass 1 failed. with 2
NMAKE : fatal error U1077: 'C:\dev\cmake-2.8.7-win32-x86\bin\cmake.exe' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\nmake.exe"' : return code '0x2'
Stop.
I tried letting FLTK install itself to the default location, which didn't make any difference.
So, can anyone help me get this working?
After hours of working on this I finally figured it out.
I had to comment out these 3 lines in FLTKConfig.cmake
if(NOT " /STACK:10000000 /machine:X86 " STREQUAL "")
set(FLTK_EXE_LINKER_FLAGS " /STACK:10000000 /machine:X86 ")
endif(NOT " /STACK:10000000 /machine:X86 " STREQUAL "")
They were causing it to add an ';' character into the command line for link.exe,causing it to try to link with ;.obj.
I also had to rebuild FLTK, and change all occurences of "/MD" to "/MT" in CMakeCache.txt.
Site manager for FLTK here.
I don't have enough rep to add a comment to the OP.
The http://easysw.com/ url in the OP's message is no longer valid.
For up to date download for FLTK source code, please refer to http://fltk.org/
Just click on the "Download" link. There you will find up to date source code downloads for tar files and SVN access info.