By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,668 Members | 1,626 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,668 IT Pros & Developers. It's quick & easy.

CMAKE Windows program prints nothing

P: 88
Hey, I've had an project on Linux, but I wanna also be able to work on windows, now the CMakeLists.txt file apparently can make the makefile using MinGW or Cygwin's g++. Once the program is built with mingw32-make or cygwin's make command and ran, it does nothing.

Running in GDB it states "(gdb) During startup program exited with code 0xc0000139.", Do anyone know what this means? No very useful info found so far.

I was wondering if anyone see what's wrong with the CMakeLIsts.txt file or my configuration?

Cygwin and mingw is in my path and I've verified it can find them.

I'm using a configuration header "Config.hpp" which cmake sets up based on whether it's debug or release. This should be working correctly and the program should so "printf("DEBUG BUILD!\n");" if it is a debug build. It did at one point print, but I can't see why it wont now.

CMakeLists.txt:
Expand|Select|Wrap|Line Numbers
  1. # Set cmake minimum
  2. cmake_minimum_required(VERSION 3.11)
  3.  
  4. set(BUILD_TYPE_DEBUG "Debug")
  5. set(BUILD_TYPE_RELEASE "Release")
  6. set(CMAKE_BUILD_TYPE ${BUILD_TYPE_DEBUG})
  7. set(BUILD_TYPE ${BUILD_TYPE_DEBUG})
  8. set(PROJECT_VERSION "v0.1")
  9.  
  10. # Set cmake options
  11. set(CMAKE_CXX_STANDARD 14)
  12. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  13. set(CMAKE_CXX_EXTENSIONS OFF)
  14. set(CMAKE_C_COMPILER gcc)
  15. set(CMAKE_CXX_COMPILER g++)
  16. set(CMAKE_GENERATOR "Unix Makefiles" CACHE INTERNAL "" FORCE)
  17.  
  18. # Set project name
  19. set(PROJECT_NAME "ecs")
  20.  
  21. # Set project name
  22. project(${PROJECT_NAME})
  23.  
  24. # Set the output to the bin folder
  25. set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
  26. set(PROJECT_SOURCE_DIR ${PROJECT_SOURCE_DIR}/source)
  27. set(CMAKE_SOURCE_DIR ${PROJECT_SOURCE_DIR})
  28.  
  29. # Configure a header file to pass some of the CMake settings
  30. # to the source code
  31. configure_file(
  32.   "${PROJECT_SOURCE_DIR}/config/Config.hpp.in"
  33.   "${PROJECT_SOURCE_DIR}/config/Config.hpp"
  34.   @ONLY
  35. )
  36.  
  37. # Add all cpp files used in the program
  38. add_executable(${PROJECT_NAME} 
  39.     #src
  40.   ${PROJECT_SOURCE_DIR}/src/main.cpp
  41. )
  42.  
main.cpp:
Expand|Select|Wrap|Line Numbers
  1. #include "../config/Config.hpp"
  2.  
  3. #include <stdio.h>
  4. #include <iostream>
  5.  
  6. int main(int argc, char const *argv[])
  7. {
  8.     #if IS_BUILD_TYPE_DEBUG()
  9.         printf("DEBUG BUILD!\n");
  10.     #endif
  11.     #if defined(PROJECT_VERSION)
  12.         printf("Project version: %s\n", PROJECT_VERSION);
  13.     #endif
  14. }
  15.  
Dec 19 '18 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.