I am a newer of linux, I build a hello world as following command:
g++ -shared -fPIC helloworld.cpp -o hw
./hw
causes
Segmentation fault (core dumped)
why?
g++ helloworld.cpp -o hw
./hw
work well.
I am a newer of linux, I build a hello world as following command:
g++ -shared -fPIC helloworld.cpp -o hw
./hw
causes
Segmentation fault (core dumped)
why?
g++ helloworld.cpp -o hw
./hw
work well.
The first command builds a shared library instead of a executable file. Shared libraries are different from normal executable files. They (usually) cannot be executed directly, but can be used by other programs.