0

I am currently working on a project, where I have to implement a snake game which compiles just fine on itself with g++, the problem is when I try to integrate it into the greater project which compiles using CMake it throws a segmentation fault, even though I narrowed the whole main file down to being

 #include <ncurses.h>
 int main(){
     initscr();
     return 0;
 }

I have no clue why this is happening and haven't been able to find a solution through other fora. I'm currently running Ubuntu 16.04 and cmake version 3.5.1 as well as ncurses5 v6.

melpomene
  • 84,125
  • 8
  • 85
  • 148
  • 1
    Use your debugger, and step through the code. – Richard Critten Apr 22 '18 at 07:25
  • 2
    @RichardCritten There's not much to step through here. –  Apr 22 '18 at 07:31
  • Do you get the segfault too if you compile *just* this source file into a program? If you do, it sounds like a problem with your set-up, not your program. If you don't, see if you can figure out which additional source file causes the problem. –  Apr 22 '18 at 07:34
  • @Richard - I tried running the program with gdb, but it doesn't return anything. – Jakob Guldberg Aaes Apr 22 '18 at 07:36
  • @hvd - If I compile just that snip `g++ -o test testmain.cpp -lncurses` it compiles fine. And the whole game itself compiles fine with this. So I suspect there is some issue with CMake and curses, even though I have included it in the CMakelists.txt as it should. – Jakob Guldberg Aaes Apr 22 '18 at 07:42
  • I found something that helped the problem, but it doesn't make sense to me. In the CMakeLists.txt I had `TARGET_LINK_LIBRARIES( Enable ${OpenCV_LIBS} dlib::dlib)`, and changing it to `TARGET_LINK_LIBRARIES( Enable ${OpenCV_LIBS})` solves the core dump problem even though it is totally unrelated to the snake game... – Jakob Guldberg Aaes Apr 22 '18 at 09:27

0 Answers0