OS: Ubuntu 14.04 (Trusty Tahr)
Write two .c files named dtest1.c and dtest2.c.
File dtest1.c
int p = 2;
void print()
{
printf("this is the first DLL test!\n");
}
File dtest2.c
int p = 3;
void print()
{
printf("this is the second DLL test!\n");
}
Then, compile them to get two files named dtest1.so and dtest2.so:
gcc -O -fpic -shared -o dtest1.so dtest1.c
gcc -O -fpic -shared -o dtest2.so dtest2.c
Write a .c file named dtest3.c.
File dtest3.c
#include "dtest1.so"
int main ()
{
print();
return 0;
}
So far now, everything is good. There isn't any error (only a warning).
Then:
gcc -o dtest3 dtest3.c dtest1.so
Error:
In file included from dtest3.c:1:0:
dtest1.so:17:1: warning: null character(s) ignored [enabled by default]
dtest1.so:17:2: error: stray ‘\260’ in program
......
...... /*omit too many similar information */
dtest1.so:18:2: error: stray ‘\212’ in program
dtest1.so:18:2: error: stray ‘\1’ in program
In file included from dtest3.c:1:0:
dtest1.so:18:956: warning: null character(s) ignored [enabled by default]
In file included from dtest3.c:1:0:
dtest1.so:18:2: error: stray ‘\244’ in program
dtest1.so:18:2: error: stray ‘\1’ in program
In file included from dtest3.c:1:0:
dtest1.so:18:980: warning: null character(s) ignored [enabled by default]
dtest1.so:18:982: warning: null character(s) preserved in literal [enabled by default]
dtest1.so:18:982: warning: missing terminating " character [enabled by default]
In file included from dtest3.c:1:0:
dtest1.so:18:2: error: missing terminating " character
What's wrong with that?