In general you can't just blindly copy and paste all of the code from one project into another and expect it to compile and run with no changes.

Make a debug version of the project, run it in the debugger and examine the stack trace when the seg fault occurs. That will give you a clue about where to start looking for the source of the problem.

A seg fault usually means you are trying to access something through an uninitialized pointer, violating the bounds of an array by using an invalid index, using a null pointer, something in your program has corrupted the stack, or any number of other things.