search

Home  >  Q&A  >  body text

c++ - A segfault occurs before the main function is executed, and gdb cannot debug. It is probably related to the g++ compilation parameters.

Try to use c++ to package openssl, first write a static library libtest.a. Depends on -lssl -lcrytpo -lpthread.
Directory Structure:

There are two test files: client.cpp, server.cpp
The commands used to compile the executable program are as follows:
g++ -g -o2 -fpic client.cpp -I../include -L ../lib -ltest -shared -u -lssl -lcrypto -lpthread -o client
Compilation successful;
Execution error, gdb debugging found that it crashed before the main function started.
Supplement: Comment all the main function codes, and the above compilation will not work. Remove the -shared parameter when compiling, and the program will end normally.

仅有的幸福仅有的幸福2750 days ago623

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-05-16 13:25:33

    There is a problem with the code I wrote to compile the static library.

    reply
    0
  • Cancelreply