Created
August 3, 2017 23:55
-
-
Save zao/56e15d9cad20fd4bb48b8f1ff9d29601 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat so.cc | |
extern char** environ; | |
#include <iostream> | |
void f() { | |
for (size_t i = 0; environ[i]; ++i) { | |
std::cerr << environ[i] << std::endl; | |
} | |
} | |
$ clang++ -shared -o so.so so.cc -fPIC | |
$ clang++ -shared -o so.so so.cc -fPIC -Wl,-z,defs | |
/tmp/so-693756.o: In function `f()': | |
so.cc:(.text+0x13): undefined reference to `environ' | |
so.cc:(.text+0x33): undefined reference to `environ' | |
clang++: error: linker command failed with exit code 1 (use -v to see invocation) | |
$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment