I have a CMakelist.txt where i add external header files and lib. files for my build.
Now when I call custom headers ("myown.h") in my main function I get errors when running CMake linking.
So I found out that I have to add my own headers and .cpp to a library with add_library and then add them under target_link_libraries.
However I get a link error while building as long as I want to call the code from my own header.
Does anyone have an idea where the error is or how I can continue?
Here is my CMakelist:
cmake_minimum_required(VERSION 3.0.0)
project(MIELE_OCULUS VERSION 0.1.0)
#Hier weden die include files gefunden
INCLUDE_DIRECTORIES(
C:/Projekte/Cpp/dev/vcpkg/installed/x64-windows/include
)
#Hier werden die lib files gefunden
LINK_DIRECTORIES(
C:/Projekte/Cpp/dev/vcpkg/installed/x64-windows/lib,
C:/Program Files (x86)/Windows Kits/10/Lib/10.0.19041.0/um/x64
)
add_library(
test
testclass.h
testclass.cpp
)
add_executable(MIELE_OCULUS
main.cpp
)
TARGET_LINK_LIBRARIES(MIELE_OCULUS
cpprest_2_10
WS2_32
test
)
UPDATE:
With these changes in CMakelist.txt you can build the program, but after changing the src code or cleaning up the CMake project, linking errors will occur again.
changed CMakelist:
cmake_minimum_required(VERSION 3.0.0)
project(MIELE_OCULUS VERSION 0.1.0)
add_library(
mylib
includes/mylib/testclass.h
includes/mylib/testclass.cpp
)
#Hier weden die include files gefunden
TARGET_INCLUDE_DIRECTORIES(mylib PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/mylib>
$<INSTALL_INTERFACE:include/mylib> # <prefix>/include/mylib
)
INCLUDE_DIRECTORIES(
C:/Projekte/Cpp/dev/vcpkg/installed/x64-windows/include
C:/Projekte/Cpp/dev/Miele_Oculus
)
#Hier werden die lib files gefunden
LINK_DIRECTORIES(
C:/Projekte/Cpp/dev/vcpkg/installed/x64-windows/lib
C:/Program Files (x86)/Windows Kits/10/Lib/10.0.19041.0/um/x64
)
add_executable(MIELE_OCULUS
main.cpp
)
TARGET_LINK_LIBRARIES(MIELE_OCULUS
cpprest_2_10
WS2_32
mylib
)
Here is the verbose output:
Der Buildvorgang wurde am 01.11.2020 16:19:04 gestartet.
Projekt "C:\Projekte\Cpp\dev\Miele_Oculus\build\ALL_BUILD.vcxproj" auf Knoten "1" (Standardziele).
Das Projekt "C:\Projekte\Cpp\dev\Miele_Oculus\build\ALL_BUILD.vcxproj" (1) erstellt "C:\Projekte\Cpp\dev\Miele_Oculus\b
uild\ZERO_CHECK.vcxproj" (2) auf Knoten "1" (Standardziele).
InitializeBuildStatus:
"x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" wird erstellt, da "AlwaysCreate" angegeben wurde.
CustomBuild:
Alle Ausgaben sind aktuell.
FinalizeBuildStatus:
Die Datei "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" wird gelöscht.
Aktualisieren des Timestamps von "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate".
Die Erstellung von Projekt "C:\Projekte\Cpp\dev\Miele_Oculus\build\ZERO_CHECK.vcxproj" ist abgeschlossen (Standardziele
).
Das Projekt "C:\Projekte\Cpp\dev\Miele_Oculus\build\ALL_BUILD.vcxproj" (1) erstellt "C:\Projekte\Cpp\dev\Miele_Oculus\b
uild\MIELE_OCULUS.vcxproj" (3) auf Knoten "1" (Standardziele).
Das Projekt "C:\Projekte\Cpp\dev\Miele_Oculus\build\MIELE_OCULUS.vcxproj" (3) erstellt "C:\Projekte\Cpp\dev\Miele_Oculu
s\build\mylib.vcxproj" (4) auf Knoten "1" (Standardziele).
InitializeBuildStatus:
"mylib.dir\Debug\mylib.tlog\unsuccessfulbuild" wird erstellt, da "AlwaysCreate" angegeben wurde.
CustomBuild:
Alle Ausgaben sind aktuell.
VcpkgTripletSelection:
Using triplet "x64-windows" from "C:\Projekte\Cpp\dev\vcpkg\installed\x64-windows"
ClCompile:
Alle Ausgaben sind aktuell.
Lib:
Alle Ausgaben sind aktuell.
mylib.vcxproj -> C:\Projekte\Cpp\dev\Miele_Oculus\build\Debug\mylib.lib
AppLocalFromInstalled:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -noprofile -File "C:\Projekte\Cpp\d
ev\vcpkg\scripts\buildsystems\msbuild\applocal.ps1" "C:\Projekte\Cpp\dev\Miele_Oculus\build\Debug\mylib.lib" "C:\Proj
ekte\Cpp\dev\vcpkg\installed\x64-windows\debug\bin" "mylib.dir\Debug\mylib.tlog\mylib.write.1u.tlog" "mylib.dir\Debug
\vcpkg.applocal.log"
FinalizeBuildStatus:
Die Datei "mylib.dir\Debug\mylib.tlog\unsuccessfulbuild" wird gelöscht.
Aktualisieren des Timestamps von "mylib.dir\Debug\mylib.tlog\mylib.lastbuildstate".
Die Erstellung von Projekt "C:\Projekte\Cpp\dev\Miele_Oculus\build\mylib.vcxproj" ist abgeschlossen (Standardziele).
InitializeBuildStatus:
Aktualisieren des Timestamps von "MIELE_OCULUS.dir\Debug\MIELE_OCULUS.tlog\unsuccessfulbuild".
CustomBuild:
Alle Ausgaben sind aktuell.
VcpkgTripletSelection:
Using triplet "x64-windows" from "C:\Projekte\Cpp\dev\vcpkg\installed\x64-windows"
ClCompile:
Alle Ausgaben sind aktuell.
Link:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX64\x64\link.exe /ERR
ORREPORT:QUEUE /OUT:"C:\Projekte\Cpp\dev\Miele_Oculus\build\Debug\MIELE_OCULUS.exe" /INCREMENTAL /NOLOGO /LIBPATH:"C:
/Projekte/Cpp/dev/vcpkg/installed/x64-windows/lib" /LIBPATH:"C:/Projekte/Cpp/dev/vcpkg/installed/x64-windows/lib/Debu
g" /LIBPATH:C:/Program /LIBPATH:C:/Program/Debug /LIBPATH:C:/Projekte/Cpp/dev/Miele_Oculus/Files /LIBPATH:C:/Projekte
/Cpp/dev/Miele_Oculus/Files/Debug /LIBPATH:"C:/Projekte/Cpp/dev/Miele_Oculus/(" /LIBPATH:"C:/Projekte/Cpp/dev/Miele_O
culus/(/Debug" /LIBPATH:C:/Projekte/Cpp/dev/Miele_Oculus/x86 /LIBPATH:C:/Projekte/Cpp/dev/Miele_Oculus/x86/Debug /LIB
PATH:"C:/Projekte/Cpp/dev/Miele_Oculus/)" /LIBPATH:"C:/Projekte/Cpp/dev/Miele_Oculus/)/Debug" /LIBPATH:/Windows /LIBP
ATH:/Windows/Debug /LIBPATH:C:/Projekte/Cpp/dev/Miele_Oculus/Kits/10/Lib/10.0.19041.0/um/x64 /LIBPATH:C:/Projekte/Cpp
/dev/Miele_Oculus/Kits/10/Lib/10.0.19041.0/um/x64/Debug /LIBPATH:"C:\Projekte\Cpp\dev\vcpkg\installed\x64-windows\deb
ug\lib" /LIBPATH:"C:\Projekte\Cpp\dev\vcpkg\installed\x64-windows\debug\lib\manual-link" cpprest_2_10.lib WS2_32.lib
Debug\mylib.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.l
ib advapi32.lib "C:\Projekte\Cpp\dev\vcpkg\installed\x64-windows\debug\lib*.lib" /MANIFEST /MANIFESTUAC:"level='asIn
voker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:/Projekte/Cpp/dev/Miele_Oculus/build/Debug/MIELE_OCULUS.pdb"
/SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:/Projekte/Cpp/dev/Miele_Oculus/build/Debug/MIELE_OCULUS
.lib" /MACHINE:X64 /machine:x64 MIELE_OCULUS.dir\Debug\main.obj
LINK : fatal error LNK1104: Datei "C:\Projekte\Cpp\dev\Miele_Oculus\build\Debug\MIELE_OCULUS.exe" kann nicht geöffnet w
erden. [C:\Projekte\Cpp\dev\Miele_Oculus\build\MIELE_OCULUS.vcxproj]
Die Erstellung des Projekts "C:\Projekte\Cpp\dev\Miele_Oculus\build\MIELE_OCULUS.vcxproj" ist abgeschlossen (Standardzi
ele) -- FEHLER.
Die Erstellung des Projekts "C:\Projekte\Cpp\dev\Miele_Oculus\build\ALL_BUILD.vcxproj" ist abgeschlossen (Standardziele
) -- FEHLER.
Fehler beim Buildvorgang.
"C:\Projekte\Cpp\dev\Miele_Oculus\build\ALL_BUILD.vcxproj" (Standardziel) (1) ->
"C:\Projekte\Cpp\dev\Miele_Oculus\build\MIELE_OCULUS.vcxproj" (Standardziel) (3) ->
(Link Ziel) ->
LINK : fatal error LNK1104: Datei "C:\Projekte\Cpp\dev\Miele_Oculus\build\Debug\MIELE_OCULUS.exe" kann nicht geöffnet
werden. [C:\Projekte\Cpp\dev\Miele_Oculus\build\MIELE_OCULUS.vcxproj]
0 Warnung(en)
1 Fehler
Verstrichene Zeit 00:00:00.90
Now it works
1:
Adding a header into add_library call doesn't add include directories for the header.
You need to add these directories manually, with INCLUDE_DIRECTORIES or
TARGET_INCLUDE_DIRECTORIES
I added this part:
#Eigene header Dateien include
TARGET_INCLUDE_DIRECTORIES(mylib PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/includes/mylib>
$<INSTALL_INTERFACE:includes/mylib> # <prefix>/includes/mylib
Thanks a lot to Tsyvarev ! :)
2:
The "strange" behavoir was a bad mistake from me, cause I didnt known that i delete the output terminal in windows bevor i start a new build in the command window
Thank you guys!
Related
I'm trying to build Flutter with native C++ dependency, but every time I try to add CMake subproject it fails due to a problem with creating a directory. It's probably something simple, but it's really hard to find any guide on how to add dependencies for the Windows platform, so I'm improvising (a lot).
Flutter Doctor summary:
[√] Flutter (Channel stable, 2.5.3, on Microsoft Windows [Version 10.0.22000.376], locale pl-PL)
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.6)
[√] Android Studio (version 2020.3)
[√] IntelliJ IDEA Ultimate Edition (version 2021.2)
[√] VS Code (version 1.63.0)
[√] Connected device (3 available)
Steps to reproduce:
Create a new Flutter project with support for the Windows platform.
Copy library (e.g. DirectXText) into the project root folder.
Add the library in the [project]\windows\CMakeLists.txt by adding a subdirectory (add_subdirectory(../DirectXTex "${CMAKE_BINARY_DIR}/${PROJECT_NAME}_directxtex")):
cmake_minimum_required(VERSION 3.15)
project(stackoverflow_windows_question LANGUAGES CXX)
set(BINARY_NAME "stackoverflow_windows_question")
cmake_policy(SET CMP0063 NEW)
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
# Configure build options.
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(IS_MULTICONFIG)
set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
CACHE STRING "" FORCE)
else()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug" CACHE
STRING "Flutter build mode" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Profile" "Release")
endif()
endif()
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
# Use Unicode for all projects.
add_definitions(-DUNICODE -D_UNICODE)
# Compilation settings that should be applied to most targets.
function(APPLY_STANDARD_SETTINGS TARGET)
target_compile_features(${TARGET} PUBLIC cxx_std_17)
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
target_compile_options(${TARGET} PRIVATE /EHsc)
target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
endfunction()
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
# Flutter library and tool build rules.
add_subdirectory(${FLUTTER_MANAGED_DIR})
# Application build
add_subdirectory("runner")
# Generated plugin build rules, which manage building the plugins and adding
# them to the application.
include(flutter/generated_plugins.cmake)
add_subdirectory(../DirectXTex "${CMAKE_BINARY_DIR}/${PROJECT_NAME}_directxtex") # NEW LINE
# === Installation ===
# Support files are copied into place next to the executable, so that it can
# run in place. This is done instead of making a separate bundle (as on Linux)
# so that building and running from within Visual Studio will work.
set(BUILD_BUNDLE_DIR "$<TARGET_FILE_DIR:${BINARY_NAME}>")
# Make the "install" step default, as it's required to run.
set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
endif()
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
COMPONENT Runtime)
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
COMPONENT Runtime)
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
if(PLUGIN_BUNDLED_LIBRARIES)
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endif()
# Fully re-copy the assets directory on each build to avoid having stale files
# from a previous install.
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
install(CODE "
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
" COMPONENT Runtime)
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
# Install the AOT library on non-Debug builds only.
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
CONFIGURATIONS Profile;Release
COMPONENT Runtime)
Try to build it in verbose mode:
flutter build windows -v
Wait for the build to fail:
[ +78 ms] PostBuildEvent:
[ ] setlocal
[ ] "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -DBUILD_TYPE=Release -P cmake_install.cmake
[ ] if %errorlevel% neq 0 goto :cmEnd
[ ] :cmEnd
[ ] endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
[ ] :cmErrorLevel
[ ] exit /b %1
[ ] :cmDone
[ ] if %errorlevel% neq 0 goto :VCEnd
[ ] :VCEnd
[ +83 ms] -- Install configuration: "Release"
[ +1 ms] CMake Error at stackoverflow_windows_question_directxtex/cmake_install.cmake:41 (file):
[ ] file cannot create directory:
[ ] C:/Users/jbili/Documents/Flutter-Projects/stackoverflow_windows_question/build/windows/$<TARGET_FILE_DIR:stackoverflow_windows_question>/lib.
[ ] Maybe need administrative privileges.
[ ] Call Stack (most recent call first):
[ ] cmake_install.cmake:47 (include)
[ +7 ms] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: Polecenie „setlocal [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ +1 ms] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -DBUILD_TYPE=Release -P
cmake_install.cmake [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: :cmEnd [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: :cmErrorLevel [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: exit /b %1 [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: :cmDone [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: :VCEnd” zostało zakończone przez kod 1. [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ ] Kompilowanie projektu „C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj” wykonane (domyślne elementy docelowe) — NIEPOWODZENIE.
[ ] Kompilacja NIE POWIODŁA SIĘ.
[ ] „C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj” (domyślny element docelowy) (1)->
[ ] (element docelowy PostBuildEvent) ->
[ ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: Polecenie „setlocal [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -DBUILD_TYPE=Release -P
cmake_install.cmake [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: :cmEnd [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: :cmErrorLevel [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: exit /b %1 [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: :cmDone [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ ] C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB3073: :VCEnd” zostało zakończone przez kod 1. [C:\Users\jbili\Documents\Flutter-Projects\stackoverflow_windows_question\build\windows\INSTALL.vcxproj]
[ ] Ostrzeżenia: 0
[ ] Liczba błędów: 1
[ ] Czas, który upłynął: 00:00:41.72
[ +12 ms] Building Windows application... (completed in 44,1s)
[ ] "flutter windows" took 44 278ms.
[ +2 ms] Build process failed.
[ ]
#0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1 _runBuild (package:flutter_tools/src/windows/build_windows.dart:299:5)
<asynchronous suspension>
#2 buildWindows (package:flutter_tools/src/windows/build_windows.dart:78:5)
<asynchronous suspension>
#3 BuildWindowsCommand.runCommand (package:flutter_tools/src/commands/build_windows.dart:55:5)
<asynchronous suspension>
#4 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1125:27)
<asynchronous suspension>
#5 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#6 CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#7 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:288:9)
<asynchronous suspension>
#8 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#9 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:236:5)
<asynchronous suspension>
#10 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
<asynchronous suspension>
#11 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#12 main (package:flutter_tools/executable.dart:92:3)
<asynchronous suspension>
[ +69 ms] ensureAnalyticsSent: 68ms
[ ] Running shutdown hooks
[ ] Shutdown hooks complete
[ ] exiting with code 1
As you can see it fails, because it can't create directory C:/Users/jbili/Documents/Flutter-Projects/stackoverflow_windows_question/build/windows/$<TARGET_FILE_DIR:stackoverflow_windows_question>/lib, because the directory path looks incorrectly. I think that $<TARGET_FILE_DIR:stackoverflow_windows_question> has not been converted at some point by CMake, but I don't know why.
Could you help me solve this problem?
I'm not sure, but Have you tried to run the script using Admin privileges, this may solve your problem because the error said "Maybe need administrative privileges."
I am following this tutorial on setting up gdnative.
I have installed c++ tools through visual studio, python 3.2, and scons 4.1.0
I am stuck trying to get scons to build this gdnative example. The issue I'm having appears to be scons not being able to find #include files. I have tried using a relative file paths to a sub directory godot-cpp/, relative paths to a sibling directory ../godot-cpp/, and using a full path to the sibling directory E:/Projects/Godot Projects/Units/godot-cpp/ but I am getting the same error every time. I have provided a screenshot to show the file structure. I am running scons from X64 Native Tools Command Prompt for VS 2019
Edit - have now also tried while running as administrator, same error
Top Left: The project I am trying to build and the cpp files I need to include in sibling directories.
Top Right: The contents of the project folder. The godot-cpp/ subdirectory is a copy of the folder of the same name from the Top Left.
Bottom Left: Contents of godot-cpp/
Bottom Right: Contents of godot-cpp/godot-headers. The highlighted file is the one it can't seem to find.
Relative path to sub directory:
E:\Projects\Godot Projects\Units\gdnative_cpp_example>scons platform=windows
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fosrc\gdexample.obj /c src\gdexample.cpp /TP /nologo -DWIN32 -D_WIN32 -D_WINDOWS -W3 -GR -D_CRT_SECURE_NO_WARNINGS -EHsc -D_DEBUG -MDd /I. /Igodot-cpp\godot_headers /Igodot-cpp\include /Igodot-cpp\include\core /Igodot-cpp\include\gen /Isrc
gdexample.cpp
godot-cpp\include\core\Godot.hpp(7): fatal error C1083: Cannot open include file: 'gdnative_api_struct.gen.h': No such file or directory
scons: *** [src\gdexample.obj] Error 2
scons: building terminated because of errors.
Relative path to sibling directory:
E:\Projects\Godot Projects\Units\gdnative_cpp_example>scons platform=windows
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fosrc\gdexample.obj /c src\gdexample.cpp /TP /nologo -DWIN32 -D_WIN32 -D_WINDOWS -W3 -GR -D_CRT_SECURE_NO_WARNINGS -EHsc -D_DEBUG -MDd /I. "/IE:\Projects\Godot Projects\Units\godot-cpp\godot_headers" "/IE:\Projects\Godot Projects\Units\godot-cpp\include" "/IE:\Projects\Godot Projects\Units\godot-cpp\include\core" "/IE:\Projects\Godot Projects\Units\godot-cpp\include\gen" /Isrc
gdexample.cpp
E:\Projects\Godot Projects\Units\godot-cpp\include\core\Godot.hpp(7): fatal error C1083: Cannot open include file: 'gdnative_api_struct.gen.h': No such file or directory
scons: *** [src\gdexample.obj] Error 2
scons: building terminated because of errors.
Full path to sibling directory:
E:\Projects\Godot Projects\Units\gdnative_cpp_example>scons platform=windows
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fosrc\gdexample.obj /c src\gdexample.cpp /TP /nologo -DWIN32 -D_WIN32 -D_WINDOWS -W3 -GR -D_CRT_SECURE_NO_WARNINGS -EHsc -D_DEBUG -MDd /I. "/IE:\Projects\Godot Projects\Units\godot-cpp\godot_headers" "/IE:\Projects\Godot Projects\Units\godot-cpp\include" "/IE:\Projects\Godot Projects\Units\godot-cpp\include\core" "/IE:\Projects\Godot Projects\Units\godot-cpp\include\gen" /Isrc
gdexample.cpp
E:\Projects\Godot Projects\Units\godot-cpp\include\core\Godot.hpp(7): fatal error C1083: Cannot open include file: 'gdnative_api_struct.gen.h': No such file or directory
scons: *** [src\gdexample.obj] Error 2
scons: building terminated because of errors.
It's getting stuck following the include statement from Godot.hpp line 7 to gdnative_api_struct.gen.h. It looks like it can resolve the path just fine but it can't open them for some reason.
SConstruct file - Came with the project I'm trying to build. Only modification was changing the paths to godot-cpp/ and godot-cpp/headers/.
#!python
import os, subprocess
opts = Variables([], ARGUMENTS)
# Gets the standard flags CC, CCX, etc.
env = DefaultEnvironment()
# Define our options
opts.Add(EnumVariable('target', "Compilation target", 'debug', ['d', 'debug', 'r', 'release']))
opts.Add(EnumVariable('platform', "Compilation platform", '', ['', 'windows', 'x11', 'linux', 'osx']))
opts.Add(EnumVariable('p', "Compilation target, alias for 'platform'", '', ['', 'windows', 'x11', 'linux', 'osx']))
opts.Add(BoolVariable('use_llvm', "Use the LLVM / Clang compiler", 'no'))
opts.Add(PathVariable('target_path', 'The path where the lib is installed.', 'demo/bin/'))
opts.Add(PathVariable('target_name', 'The library name.', 'libgdexample', PathVariable.PathAccept))
# Local dependency paths, adapt them to your setup
# These next two lines are where I changed the paths <-----------------
godot_headers_path = "../godot-cpp/godot_headers/"
cpp_bindings_path = "../godot-cpp/"
cpp_library = "libgodot-cpp"
# only support 64 at this time..
bits = 64
# Updates the environment with the option variables.
opts.Update(env)
# Process some arguments
if env['use_llvm']:
env['CC'] = 'clang'
env['CXX'] = 'clang++'
if env['p'] != '':
env['platform'] = env['p']
if env['platform'] == '':
print("No valid target platform selected.")
quit();
# Check our platform specifics
# I'm using windows so I cut the other options for readability
if env['platform'] == "windows":
env['target_path'] += 'win64/'
cpp_library += '.windows'
# This makes sure to keep the session environment variables on windows,
# that way you can run scons in a vs 2017 prompt and it will find all the required tools
env.Append(ENV = os.environ)
env.Append(CCFLAGS = ['-DWIN32', '-D_WIN32', '-D_WINDOWS', '-W3', '-GR', '-D_CRT_SECURE_NO_WARNINGS'])
if env['target'] in ('debug', 'd'):
env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '-MDd'])
else:
env.Append(CCFLAGS = ['-O2', '-EHsc', '-DNDEBUG', '-MD'])
if env['target'] in ('debug', 'd'):
cpp_library += '.debug'
else:
cpp_library += '.release'
cpp_library += '.' + str(bits)
# make sure our binding library is properly includes
env.Append(CPPPATH=['.', godot_headers_path, cpp_bindings_path + 'include/', cpp_bindings_path + 'include/core/', cpp_bindings_path + 'include/gen/'])
env.Append(LIBPATH=[cpp_bindings_path + 'bin/'])
env.Append(LIBS=[cpp_library])
# tweak this if you want to use different folders, or more folders, to store your source code in.
env.Append(CPPPATH=['src/'])
sources = Glob('src/*.cpp')
library = env.SharedLibrary(target=env['target_path'] + env['target_name'], source=sources)
Default(library)
# Generates help for the -h scons option.
Help(opts.GenerateHelpText(env))
I had this exact same problem today. On the line you changed in your SConstruct file you reference the godot headers directory (the one which contains gdnative_api_struct.gen.h) as godot_headers, but in your file system this folder is called godot-headers (- not _). Because of this scons cannot find the file. Changing the directory's name in the file system to godot_headers solved the problem for me.
I've been tasked with converting and building a large framework into a CMake tree and binary. Currently, the framework is built using VS 2017, creating a solution named Framework_static_vc15.sln. As this is a large project, I opted to use a converter to create the CMakeLists.txt files for each part of this project. Here is the link to the converter I used.
https://cmakeconverter.readthedocs.io/en/develop/intro.html
This converter successfully creates all the text files needed, and I can run the command
cmake -S . -B build
To create a directory that I should be able to run cmake --build build on.
However, when I run the above command, the build fails every time with the following error
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: The command "setlocal [C:\Work\SVN\Software\Framework\build\Source\UeiDaqCore\UeiDaqCore_vc15.vcx
proj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: cd C:\Work\SVN\Software\Framework\Source\UeiDaqCore [C:\Work\SVN\Software\Framework\build\Source\
UeiDaqCore\UeiDaqCore_vc15.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\Work\SVN\Software\Framework\build\Source\UeiDaqCore\UeiDaqC
ore_vc15.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: C: [C:\Work\SVN\Software\Framework\build\Source\UeiDaqCore\UeiDaqCore_vc15.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\Work\SVN\Software\Framework\build\Source\UeiDaqCore\UeiDaqC
ore_vc15.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: if not exist ..\..\CPP\lib mkdir ..\..\CPP\lib [C:\Work\SVN\Software\Framework\build\Source\UeiDa
qCore\UeiDaqCore_vc15.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\Work\SVN\Software\Framework\build\Source\UeiDaqCore\UeiDaqC
ore_vc15.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: copy C:\Work\SVN\Software\Framework\Source\UeiDaqCore\..\..\Output\Win32\vs15_DebugUeiDaqvc15SD.l
ib ..\..\CPP\lib [C:\Work\SVN\Software\Framework\build\Source\UeiDaqCore\UeiDaqCore_vc15.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\Work\SVN\Software\Framework\build\Source\UeiDaqCore\UeiDaqC
ore_vc15.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: cd. [C:\Work\SVN\Software\Framework\build\Source\UeiDaqCore\UeiDaqCore_vc15.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\Work\SVN\Software\Framework\build\Source\UeiDaqCore\UeiDaqC
ore_vc15.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: cd. [C:\Work\SVN\Software\Framework\build\Source\UeiDaqCore\UeiDaqCore_vc15.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\Work\SVN\Software\Framework\build\Source\UeiDaqCore\UeiDaqC
ore_vc15.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: :cmEnd [C:\Work\SVN\Software\Framework\build\Source\UeiDaqCore\UeiDaqCore_vc15.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone [C:\Work\SVN\Software\Framework\build\S
ource\UeiDaqCore\UeiDaqCore_vc15.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: :cmErrorLevel [C:\Work\SVN\Software\Framework\build\Source\UeiDaqCore\UeiDaqCore_vc15.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: exit /b %1 [C:\Work\SVN\Software\Framework\build\Source\UeiDaqCore\UeiDaqCore_vc15.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: :cmDone [C:\Work\SVN\Software\Framework\build\Source\UeiDaqCore\UeiDaqCore_vc15.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd [C:\Work\SVN\Software\Framework\build\Source\UeiDaqCore\UeiDaqC
ore_vc15.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1
38,5): error MSB3073: :VCEnd" exited with code 1. [C:\Work\SVN\Software\Framework\build\Source\UeiDaqCore\UeiDaqCore_vc
15.vcxproj]
This error is from a post build event inside a sub-project named UeiDaqCore, that arises when CMake tries to execute the following command UeiDaqCore_vc15.vcxproj -> C:\Work\SVN\Software\Framework\Output\Win32\vs15_Debug\UeiDaqCore_vc15SD.lib. CMake gives me the error list without all the paths, and here it is.
PostBuildEvent:
setlocal
cd C:\Work\SVN\Software\Framework\Source\UeiDaqCore
if %errorlevel% neq 0 goto :cmEnd
C:
if %errorlevel% neq 0 goto :cmEnd
if not exist ..\..\CPP\lib mkdir ..\..\CPP\lib
if %errorlevel% neq 0 goto :cmEnd
copy C:\Work\SVN\Software\Framework\Source\UeiDaqCore\..\..\Output\Win32\vs15_DebugUeiDaqvc15SD.lib ..\..\CPP\lib
if %errorlevel% neq 0 goto :cmEnd
cd.
if %errorlevel% neq 0 goto :cmEnd
cd.
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
:VCEnd
The system cannot find the file specified.
I looked through the Visual Studio UeiDaqCore project file for post build events named setlocal, and I also looked through the CmakeLists.txt files for setlocal post build events, but could find none.
From the error text, it looks like it's looking for a project named UeiDaqCore_vc15.vcxproj and a file named UeiDaqCore_vc15SD.lib, but cant find it. I'm not sure why, because both files are located in the folder its looking in.
I am running CMake with the administrator command prompt, as I've seen others who have had this problem, and it was caused by no admin privileges. Below this, I'll post the full CmakeLists.txt for the UeiDaqCore subproject.
project(UeiDaqCore_vc15 CXX)
################################################################################
# Source groups
################################################################################
set(no_group_source_files
ReadMe.txt
)
source_group("" FILES ${no_group_source_files})
set(Headers
../../CPP/include/UeiChannel.h
../../CPP/include/UeiConstants.h
../../CPP/include/UeiCustomScale.h
../../CPP/include/UeiDaq.h
../../CPP/include/UeiDaqAnsiC.h
../../CPP/include/UeiDaqError.h
../../CPP/include/UeiDataStream.h
../../CPP/include/UeiDevice.h
../../CPP/include/UeiDeviceEnumerator.h
../../CPP/include/UeiDriverEnumerator.h
../../CPP/include/UeiEvent.h
../../CPP/include/UeiException.h
../../CPP/include/UeiFrameUtils.h
../../CPP/include/UeiMessaging.h
../../CPP/include/UeiObject.h
../../CPP/include/UeiReader.h
../../CPP/include/UeiResourceParser.h
../../CPP/include/UeiSession.h
../../CPP/include/UeiSessionGroup.h
../../CPP/include/UeiStructs.h
../../CPP/include/Ueisystem.h
../../CPP/include/UeiTiming.h
../../CPP/include/UeiTrigger.h
../../CPP/include/UeiWriter.h
pugxml.h
resource.h
ResourceParser.h
SensorConversion.h
SignalParser.h
StdAfx.h
UeiAnsiCSession.h
UeiChannelimpl.h
UeiCJCConverter.h
UeiDaqCore.h
UeiDaqCoreVer.h
UeiDaqDriver.h
UeiDaqDriverSession.h
UeiDaqLV.h
UeiDataStreamImpl.h
UeiDeviceEnumeratorImpl.h
UeiDeviceImpl.h
UeiDriverEvent.h
UeiMessagingImpl.h
UeiObjectImpl.h
UeiReaderImpl.h
UeiRTDConverter.h
UeiSessionImpl.h
UeiSessionSettings.h
UeiTimingImpl.h
UeiTriggerImpl.h
UeiWriterImpl.h
UeiXmlParser.h
)
source_group("Headers" FILES ${Headers})
set(Sources
ResourceParser.cpp
SensorConversion.cpp
StdAfx.cpp
UeiChannel.cpp
UeiChannelImpl.cpp
UeiCJCConverter.cpp
UeiCustomScale.cpp
UeiDaqAnsiC.cpp
UeiDaqCore.cpp
UeiDaqLV.cpp
UeiDataStream.cpp
UeiDataStreamImpl.cpp
UeiDevice.cpp
UeiDeviceEnumerator.cpp
UeiDeviceEnumeratorImpl.cpp
UeiDeviceImpl.cpp
UeiDriverEnumerator.cpp
UeiException.cpp
UeiFrameUtils.cpp
UeiMessaging.cpp
UeiMessagingImpl.cpp
UeiObject.cpp
UeiObjectImpl.cpp
UeiReader.cpp
UeiReaderImpl.cpp
UeiResourceParser.cpp
UeiRTDConverter.cpp
UeiSession.cpp
UeiSessionGroup.cpp
UeiSessionImpl.cpp
UeiSessionSettings.cpp
UeiSystem.cpp
UeiTiming.cpp
UeiTimingImpl.cpp
UeiTrigger.cpp
UeiTriggerImpl.cpp
UeiWriter.cpp
UeiWriterImpl.cpp
UeiXmlParser.cpp
)
source_group("Sources" FILES ${Sources})
set(ALL_FILES
${no_group_source_files}
${Headers}
${Sources}
)
################################################################################
# Target
################################################################################
add_library(${PROJECT_NAME} STATIC ${ALL_FILES})
add_precompiled_header(${PROJECT_NAME} "StdAfx.h" "StdAfx.cpp")
use_props(${PROJECT_NAME} "${CMAKE_CONFIGURATION_TYPES}" "${DEFAULT_CXX_PROPS}")
set(ROOT_NAMESPACE UeiDaqCore)
################################################################################
# Target name
################################################################################
set_target_properties(${PROJECT_NAME} PROPERTIES
TARGET_NAME_DEBUG "${PROJECT_NAME}SD"
TARGET_NAME_RELEASE "${PROJECT_NAME}S"
)
################################################################################
# Output directory
################################################################################
set_target_properties(${PROJECT_NAME} PROPERTIES
OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../../Output/${CMAKE_VS_PLATFORM_NAME}/vs15_$<CONFIG>"
OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../Output/${CMAKE_VS_PLATFORM_NAME}/vs15_$<CONFIG>"
)
################################################################################
# Include directories
################################################################################
target_include_directories(${PROJECT_NAME} PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/../../CPP/include;"
"$ENV{UEICOMMON}/includes"
)
################################################################################
# Compile definitions
################################################################################
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"_DEBUG;"
"UEIDAQ_DEBUG"
">"
"$<$<CONFIG:Release>:"
"NDEBUG"
">"
"WIN32;"
"_WINDOWS;"
"UEIDAQSTATIC;"
"__MSWINDOWS__;"
"_MBCS"
)
set_source_files_properties(ResourceParser.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
set_source_files_properties(StdAfx.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;UEIDAQSTATIC"
)
set_source_files_properties(UeiChannel.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
set_source_files_properties(UeiChannelImpl.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
set_source_files_properties(UeiDaqCore.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
set_source_files_properties(UeiDataStream.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
set_source_files_properties(UeiDataStreamImpl.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
set_source_files_properties(UeiDevice.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
set_source_files_properties(UeiDeviceEnumerator.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
set_source_files_properties(UeiDeviceEnumeratorImpl.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
set_source_files_properties(UeiDeviceImpl.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
set_source_files_properties(UeiException.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
set_source_files_properties(UeiObject.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
set_source_files_properties(UeiObjectImpl.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
set_source_files_properties(UeiSession.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
set_source_files_properties(UeiSessionGroup.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
set_source_files_properties(UeiSessionImpl.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
set_source_files_properties(UeiTiming.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
set_source_files_properties(UeiTimingImpl.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
set_source_files_properties(UeiTrigger.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
set_source_files_properties(UeiTriggerImpl.cpp PROPERTIES
COMPILE_DEFINITIONS_DEBUG "_DEBUG"
COMPILE_DEFINITIONS_RELEASE "NDEBUG"
COMPILE_DEFINITIONS "WIN32;_WINDOWS;_MBCS;_USRDLL;UEIDAQCORE_EXPORTS"
)
################################################################################
# Compile and link options
################################################################################
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Debug>:
/Od;
/RTC1;
/MTd
>
$<$<CONFIG:Release>:
/O2;
/Ob1;
/GF;
/MT;
/Gy
>
/W3;
/nologo;
/Zi;
/GR;
${DEFAULT_CXX_EXCEPTION_HANDLING}
)
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(ResourceParser.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(StdAfx.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(UeiChannel.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(UeiChannelImpl.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(UeiDaqCore.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(UeiDataStream.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(UeiDataStreamImpl.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(UeiDevice.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(UeiDeviceEnumerator.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(UeiDeviceEnumeratorImpl.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(UeiDeviceImpl.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(UeiException.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(UeiObject.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(UeiObjectImpl.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(UeiSession.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(UeiSessionGroup.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(UeiSessionImpl.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(UeiTiming.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(UeiTimingImpl.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(UeiTrigger.cpp ${FILE_CL_OPTIONS})
string(CONCAT FILE_CL_OPTIONS
"$<$<CONFIG:Debug>:"
"/Od;/RTC1"
">"
"$<$<CONFIG:Release>:"
"/O2"
">"
)
source_file_compile_options(UeiTriggerImpl.cpp ${FILE_CL_OPTIONS})
endif()
################################################################################
# Post build events
################################################################################
add_custom_command_if(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMANDS
COMMAND $<CONFIG:Debug> if not exist ..\\..\\CPP\\lib mkdir ..\\..\\CPP\\lib
COMMAND $<CONFIG:Debug> copy $<SHELL_PATH:${OUTPUT_DIRECTORY}>UeiDaqvc15SD.lib ..\\..\\CPP\\lib
COMMAND $<CONFIG:Release> if not exist ..\\..\\CPP\\lib mkdir ..\\..\\CPP\\lib
COMMAND $<CONFIG:Release> copy $<SHELL_PATH:${OUTPUT_DIRECTORY}>UeiDaqvc15S.lib ..\\..\\CPP\\lib
)
################################################################################
# Dependencies
################################################################################
add_dependencies(${PROJECT_NAME}
UeiPDNADriver_vc15
UeiSimuDriver_vc15
)
# Link with other targets.
target_link_libraries(${PROJECT_NAME} PUBLIC
UeiPDNADriver_vc15
UeiSimuDriver_vc15
)
I'm quite new to CMake, and any help towards a possible solution would be appreciated.
EDIT: Here are the post build events for UeiDaqCore copied directly from the Visual Studio window.
copy "$(SolutionDir)\Output\$(Platform)\vs15_$(Configuration)\UeiDaqvc15D.dll" "$(SystemRoot)\System32"
if not exist ..\..\CPP\lib mkdir ..\..\CPP\lib
copy "$(SolutionDir)\Output\$(Platform)\vs15_$(Configuration)\UeiDaqvc15D.lib" ..\..\CPP\lib
It looks like the POST_BUILD custom command is malformed. Specifically, the copy command is not putting a path separator between the defined OUTPUT_DIRECTORY:
C:\Work\SVN\Software\Framework\Source\UeiDaqCore\..\..\Output\Win32\vs15_Debug
from the file name:
UeiDaqvc15SD.lib
So they get (mistakenly) concatenated:
C:\Work\SVN\Software\Framework\Source\UeiDaqCore\..\..\Output\Win32\vs15_DebugUeiDaqvc15SD.lib
Try adding path separators \\ in the custom command after $<SHELL_PATH:${OUTPUT_DIRECTORY}>:
add_custom_command_if(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMANDS
COMMAND $<CONFIG:Debug> if not exist ..\\..\\CPP\\lib mkdir ..\\..\\CPP\\lib
COMMAND $<CONFIG:Debug> copy $<SHELL_PATH:${OUTPUT_DIRECTORY}>\\UeiDaqvc15SD.lib ..\\..\\CPP\\lib
COMMAND $<CONFIG:Release> if not exist ..\\..\\CPP\\lib mkdir ..\\..\\CPP\\lib
COMMAND $<CONFIG:Release> copy $<SHELL_PATH:${OUTPUT_DIRECTORY}>\\UeiDaqvc15S.lib ..\\..\\CPP\\lib
)
I have gotten the two libraries necessary for my cpp application.
https://github.com/rbock/sqlpp11
https://github.com/rbock/sqlpp11-connector-mysql
I have them downloaded along with libmysqlclient-dev and the date library. All of the library tests work when I create a build dir in each of the project cmake .. and make and run make tests.
I import both the libraries in the root directory of the project using import_library(), and there are no errors with cmake .. from the build dir. When I run a make the code is unable to find the includes for <sqlpp11/sqlpp11.h> even though the cmake .. runs ok. The following is my root CMakeLists.txt and my src CMakeLists.txt.
cmake_minimum_required(VERSION 3.5)
project(mysql_sample)
set(HinnantDate_ROOT_DIR "${PROJECT_SOURCE_DIR}/date")
find_library(sqlpp11 REQUIRED)
include_directories(${sqlpp11_INCLUDE_DIRS})
find_library(sqlpp11-connector-mysql REQUIRED)
include_directories(${sqlpp11-connector-mysql_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/include)
add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(test)
and
add_executable(mysql_sample main.cpp)
target_link_libraries(mysql_sample ${sqlpp11_LIBRARIES})
target_link_libraries(mysql_sample ${sqlpp11-connector-mysql_LIBRARIES})
Edit 1
In response to the comment the error is
Maker Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find Sqlpp11-connector-mysql (missing:
sqlpp11-connector-mysql_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
CMake/FindSqlpp11-connector-mysql.cmake:7 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:15 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/andrew/cpp_work/sql_sample_project/build/CMakeFiles/CMakeOutput.log".
See also "/home/andrew/cpp_work/sql_sample_project/build/CMakeFiles/CMakeError.log".
With CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(mysql_sample)
set(HinnantDate_ROOT_DIR "${PROJECT_SOURCE_DIR}/date")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
find_package(Sqlpp11 REQUIRED)
include_directories(${sqlpp11_INCLUDE_DIRS})
set(include_dir "${PROJECT_SOURCE_DIR}/include")
file(GLOB_RECURSE sqlpp_headers ${include_dir}/*.h ${SQLPP11_INCLUDE_DIR}/*.h)
include_directories(${include_dir})
find_package(Sqlpp11-connector-mysql REQUIRED)
include_directories(${sqlpp11-connector-mysql_INCLUDE_DIRS})
file(GLOB_RECURSE sqlpp11-connector-mysql_headers ${include_dir}/*.h ${sqlpp11-connector-mysql_INCLUDE_DIR}/*.h)
include_directories(${include_dir})
add_executable(mysql_sample src/main.cpp)
target_link_libraries(mysql_sample ${sqlpp11_LIBRARIES})
target_link_libraries(mysql_sample ${sqlpp11-connector-mysql_LIBRARIES})
include_directories(${PROJECT_SOURCE_DIR}/include)
add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(test)
and FindSqlpp11.cmake
find_path(SQLPP11_INCLUDE_DIR sqlpp11.h
${PROJECT_SOURCE_DIR}/sqlpp11
${PROJECT_SOURCE_DIR}/include/sqlpp11
)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sqlpp11 DEFAULT_MSG SQLPP11_INCLUDE_DIR)
mark_as_advanced(SQLPP11_INCLUDE_DIR)
and FindSqlpp11-connector-mysql.cmake
find_path(Sqlpp11-connector-mysql_INCLUDE_DIR sqlpp11-connector-mysql.h
${PROJECT_SOURCE_DIR}/sqlpp11-connector-mysql
${PROJECT_SOURCE_DIR}/include/sqlpp11-connector-mysql
)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sqlpp11-connector-mysql DEFAULT_MSG sqlpp11-connector-mysql_INCLUDE_DIR)
mark_as_advanced(Sqlpp11-connector-mysql_INCLUDE_DIR)
Why is there an error here and am I on the right track?
Edit 2
I managed to get the above working, my issue was that I was not installing properly. I now get the following error from this code.
main.cpp:(.text+0x124): undefined reference to `sqlpp::mysql::connection::connection(std::shared_ptr<sqlpp::mysql::con
nection_config> const&)'
main.cpp:(.text+0x12e): undefined reference to `sqlpp::mysql::connection::~connection()'
collect2: error: ld returned 1 exit status
CMakeFiles/mysql_sample.dir/build.make:94: recipe for target 'mysql_sample' failed
make[2]: *** [mysql_sample] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/mysql_sample.dir/all' failed
make[1]: *** [CMakeFiles/mysql_sample.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Code:
include "TabSample.h"
#include <sqlpp11/sqlpp11.h>
#include <sqlpp11/mysql/mysql.h>
namespace mysql = sqlpp::mysql;
int main()
{
auto config = std::make_shared<mysql::connection_config>();
config->user = "root";
config->database = "sqlpp_mysql";
config->debug = true;
mysql::connection db(config);
TabSample tab;
for(const auto& row : db.run(sqlpp::select(all_of(tab)).from(tab).unconditionally()))
{
std::cerr << "row.alpha: " << row.alpha << ", row.beta: " << row.beta << ", row.gamma: " << row.gamma << std::endl;
};
return 0;
}
I am using gcc 4.9 and there are no errors with the make / make install, am I missing something in my CMakeLists.txt?
cmake_minimum_required(VERSION 3.5)
project(mysql_sample)
set(HinnantDate_ROOT_DIR "/usr/local/lib/date")
include_directories(/usr/local/lib/date)
if(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++0x")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
set(SQLPP11_INCLUDE_DIR /usr/local/include)
find_package(Sqlpp11 REQUIRED)
add_executable(mysql_sample src/main.cpp)
target_link_libraries(mysql_sample ${sqlpp11_LIBRARIES})
target_link_libraries(mysql_sample ${sqlpp11-connector-mysql_LIBRARIES})
include_directories(${PROJECT_SOURCE_DIR}/include)
add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(test)
CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(mysql_sample)
set(HinnantDate_ROOT_DIR "/usr/local/lib/date")
include_directories(/usr/local/lib/date)
set(CMAKE_CXX_STANDARD 11)
if(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
set(SQLPP11_INCLUDE_DIR /usr/local/include)
find_package(Sqlpp11 REQUIRED)
add_executable(mysql_sample src/main.cpp)
include_directories(${sqlpp11_INCLUDE_DIRS})
include_directories(${sqlpp11-connector-mysql_INCLUDE_DIRS})
target_link_libraries(mysql_sample ${sqlpp11_LIBRARIES})
target_link_libraries(mysql_sample ${sqlpp11-connector-mysql_LIBRARIES})
target_link_libraries(mysql_sample mysqlclient)
include_directories(${PROJECT_SOURCE_DIR}/include)
add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(test)
FindSqlpp11-connector-mysql.cmake
## -----------------------------------------------------------------------------
## Check for the library
find_library (sqlpp11-connector-mysql-mysql_LIBRARIES sqlpp11-connector-mysql-mysql
PATHS usr/local/cmake /usr/local/cmake/sqlpp11-connector-mysql-mysql /usr/local/lib /usr/lib /lib /sw/lib /usr/local/include
)
## -----------------------------------------------------------------------------
## Actions taken when all components have been found
if (sqlpp11-connector-mysql-mysql_INCLUDES AND sqlpp11-connector-mysql-mysql_LIBRARIES)
set (HAVE_sqlpp11-connector-mysql-mysql TRUE)
else (sqlpp11-connector-mysql-mysql_INCLUDES AND sqlpp11-connector-mysql-mysql_LIBRARIES)
if (NOT sqlpp11-connector-mysql-mysql_FIND_QUIETLY)
if (NOT sqlpp11-connector-mysql-mysql_INCLUDES)
message (STATUS "Unable to find sqlpp11-connector-mysql-mysql header files!")
endif (NOT sqlpp11-connector-mysql-mysql_INCLUDES)
if (NOT sqlpp11-connector-mysql-mysql_LIBRARIES)
message (STATUS "Unable to find sqlpp11-connector-mysql-mysql library files!")
endif (NOT sqlpp11-connector-mysql-mysql_LIBRARIES)
endif (NOT sqlpp11-connector-mysql-mysql_FIND_QUIETLY)
endif (sqlpp11-connector-mysql-mysql_INCLUDES AND sqlpp11-connector-mysql-mysql_LIBRARIES)
if (HAVE_sqlpp11-connector-mysql-mysql)
if (NOT sqlpp11-connector-mysql-mysql_FIND_QUIETLY)
message (STATUS "Found components for sqlpp11-connector-mysql-mysql")
message (STATUS "sqlpp11-connector-mysql-mysql_INCLUDES = ${sqlpp11-connector-mysql-mysql_INCLUDES}")
message (STATUS "sqlpp11-connector-mysql-mysql_LIBRARIES = ${sqlpp11-connector-mysql-mysql_LIBRARIES}")
endif (NOT sqlpp11-connector-mysql-mysql_FIND_QUIETLY)
else (HAVE_sqlpp11-connector-mysql-mysql)
if (sqlpp11-connector-mysql-mysql_FIND_REQUIRED)
message (FATAL_ERROR "Could not find sqlpp11-connector-mysql-mysql!")
endif (sqlpp11-connector-mysql-mysql_FIND_REQUIRED)
endif (HAVE_sqlpp11-connector-mysql-mysql)
mark_as_advanced (
HAVE_sqlpp11-connector-mysql-mysql
sqlpp11-connector-mysql-mysql_LIBRARIES
sqlpp11-connector-mysql-mysql_INCLUDES
)
and the error output:
root#beaglebone:~/cpp_work/sql_sample_project/build# cmake ..
-- Attempting to find SQLPP11 FILES
-- Unable to find SQLPP11 library files!
-- Unable to find sqlpp11-connector-mysql-mysql header files!
-- Unable to find sqlpp11-connector-mysql-mysql library files!
-- Configuring done
-- Generating done
I have a small Qt4 project which I want to build with cmake.
It has a QTcpServer and a QThread, which both include the Q_OBJECT macro.
When I'm running make I always get an RCC Parse Error after generating qrc_tcpserver.cxx.
The exact failure output is:
[ 9%] Generating qrc_tcpserver.cxx
RCC Parse Error: '/home/path/server/include/tcpserver.h' Line: 1 Column: 1 [error occurred while parsing element]
make[2]: *** [qrc_tcpserver.cxx] Fehler 1
make[1]: *** [CMakeFiles/TcpServer.dir/all] Fehler 2
make: *** [all] Fehler 2
My cmake file looks like this:
set(PROJECT_NAME TcpServer)
PROJECT(${PROJECT_NAME} )
cmake_minimum_required(VERSION 2.6)
# FOR QT4
find_package(Qt4 REQUIRED COMPONENTS QtCore QtNetwork)
SET(CMAKE_PACKAGE_QTGUI FALSE)
SET( QT_WRAP_CPP TRUE )
set(QT_USE_QTXML TRUE)
# ENABLE WARNINGS
ADD_DEFINITIONS( -Wall )
#FOR GOOGLETEST
if(test)
find_package(GTest REQUIRED)
enable_testing()
endif()
set(QT_USE_QTNETWORK TRUE)
set(INCLUDES ${PROJECT_SOURCE_DIR}/include)
set(${PROJECT_NAME}_Qt_SRC
${INCLUDES}/tcpworkerthread.h
${INCLUDES}/tcpserver.h
)
set(${PROJECT_NAME}_Qt_UI
)
set(${PROJECT_NAME}_Qt_RES
)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
IF(QT_WRAP_CPP)
MESSAGE("Wrap cpp!")
QT4_WRAP_CPP(${PROJECT_NAME}_MOC_CPP ${${PROJECT_NAME}_Qt_SRC})
ENDIF(QT_WRAP_CPP)
QT4_WRAP_UI(${PROJECT_NAME}_UI_CPP ${${PROJECT_NAME}_Qt_UI})
QT4_ADD_RESOURCES(${PROJECT_NAME}_RES_H ${${PROJECT_NAME}_Qt_SRC})
if(test)
include_directories(${GTEST_INCLUDE_DIRS} ${INCLUDES} ${QT_QTNETWORK_INCLUDE_DIR})
else()
include_directories(${INCLUDES} ${QT_QTNETWORK_INCLUDE_DIR})
endif()
if(test)
set(${PROJECT_NAME}_SRC_TEST
src_test/main.cpp
src_test/tcpservertest.cpp
src_test/tcpworkerthreadtest.cpp
)
set(PROJECT_TEST_NAME "${PROJECT_NAME}_test")
set(${PROJECT_NAME}_SRC
src/tcpserver.cpp
src/tcpworkerthread.cpp
)
else()
set(${PROJECT_NAME}_SRC
main.cpp
src/tcpserver.cpp
src/tcpworkerthread.cpp
)
endif()
set(${PROJECT_NAME}_LIB
${QT_LIBRARIES}
${QT_QTNETWORK_LIBRARIES}
)
if(test)
add_library(${PROJECT_NAME} STATIC ${${PROJECT_NAME}_SRC} )
add_executable(${PROJECT_TEST_NAME} ${${PROJECT_NAME}_SRC_TEST})
target_link_libraries(${PROJECT_TEST_NAME} ${PROJECT_NAME} ${${PROJECT_NAME}_LIB} ${GTEST_BOTH_LIBRARIES} pthread)
add_test(${PROJECT_TEST_NAME} ${PROJECT_TEST_NAME})
else()
add_executable( ${PROJECT_NAME} ${${PROJECT_NAME}_SRC} ${${PROJECT_NAME}_MOC_CPP} ${${PROJECT_NAME}_UI_CPP} ${${PROJECT_NAME}_RES_H})
target_link_libraries( ${PROJECT_NAME} ${${PROJECT_NAME}_LIB} )
endif()
I execute it without test variable, so this is set to false(I use it for generating gtest, which is not so important for me, just for playing around).
Any idea where my failure is?
I'm not very familar with CMake, but it seems you're feeding a wrong list of files to QT4_ADD_RESOURCES.
The line
QT4_ADD_RESOURCES(${PROJECT_NAME}_RES_H ${${PROJECT_NAME}_Qt_SRC})
should probably be
QT4_ADD_RESOURCES(${PROJECT_NAME}_RES_H ${${PROJECT_NAME}_Qt_RES})