Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 linux 的新人,我按照以下命令构建了一个 hello world:
g++ -shared -fPIC helloworld.cpp -o hw
./hw原因
./hw
Segmentation fault (core dumped)
为什么?
g++ helloworld.cpp -o hw ./hw
运作良好。
第一个命令构建一个共享库而不是一个可执行文件。共享库不同于普通的可执行文件。它们(通常)不能直接执行,但可以被其他程序使用。