Closed zerobytes999 closed 1 year ago
I've never seen a colon being used after the -l
or in a path. I assume you're getting an error about :libsmb2.a
not being found or something. What happens if you remove the colon?
gcc -I include -L lib -llibsmb2.a -static test.c -o mytest
/usr/bin/ld: cannot find -llibsmb2.a: No such file or directory
collect2: error: ld returned 1 exit status
this is what i get, it is strange to me also because all examples i found was without include extension and .a
i got this suggestion from here:
gcc -I include -L lib -llibsmb2 -static test.c -o mytest
/usr/bin/ld: cannot find -llibsmb2: No such file or directory
/usr/bin/ld: note to link with lib/libsmb2.a use -l:libsmb2.a or rename it to liblibsmb2.a
collect2: error: ld returned 1 exit status
You probably have to do -lsmb2
then, see the option's description at https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
do you think the steps i did were ok?
P.S
I was able to compile it without the colons but i still get the undefined error:
gcc -I include -L lib -lsmb2 -static test.c -o mytest
/usr/bin/ld: /tmp/ccRXxCUF.o: in function `main':
test.c:(.text+0x9): undefined reference to `smb2_init_context'
collect2: error: ld returned 1 exit status
You also have to move the -lsmb2
after test.c
. It has to do with how gcc looks for required symbols, see https://stackoverflow.com/questions/45135/why-does-the-order-in-which-libraries-are-linked-sometimes-cause-errors-in-gcc.
hello,
sorry for the late reply. I think i might have figured it out. I'm eventually using x86_64-w64-mingw32-gcc to compile, do i have to use the windows built library?
thank you very much. In my case, i have to build the library in windows and solve the linking issues within the project.
Hi,
first of all, great library, i was able to use the library on windows to create my own smb client/server.
however, on linux, i was able to compile the library into a static library through the following commands as suggested in one of the issues:
I found the libsmb2.a in the lib folder, created a test program test.c:
Compile commands:
gcc -I include -L lib -l:libsmb2.a -static test.c -o mytest
in the include folder, i have all the header files in include folder of libsmb2
I couldn't find why i cannot get past the undefined function issue:
can someone please help?