#libsodium.a linking

1 messages · Page 1 of 1 (latest)

wicked flint
#

g++ -shared -fPIC -o "C:\WEB\NChat\app\handlers\user.dll" "C:\WEB\NChat\app\handlers\user.cpp" -I"app/headers" -I"app/headers/libsodium-win64/include" -I"C:\cpp\global_libs\mariadb\install\include\mariadb" -L"C:\cpp\global_libs\mariadb\install\lib\mariadb" "app/headers/libsodium-win64/lib/libsodium.a" -lmariadbclient -lws2_32 -lsecur32 -lcrypt32 -ladvapi32 -lshlwapi -lbcrypt

ld.lld: error: undefined symbol: _crypto_pwhash_str
>>> referenced by C:/Users/MRNIMB~1/AppData/Local/Temp/user-4e0803.o:(hashPassword(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&))

ld.lld: error: undefined symbol: _crypto_pwhash_str_verify
>>> referenced by C:/Users/MRNIMB~1/AppData/Local/Temp/user-4e0803.o:(verifyPassword(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&))

I really don't get why that lib doesn't link, can anybody give an idea?

somber basinBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

unique siren
#

You use -L tell give the linker a DIRECTORTY to look in, the -l for the lib:
So you want -L"app/headers/libsodium-win64/lib/" -lsodium

#

Also for the love of god learn how to use cmake or use VS2022, save this massive command line

wicked flint
#

I tried -L"app/headers/libsodium-win64/lib" -lsodium too, same output

unique siren
#

Try the absolute path

wicked flint
wicked flint
#

GPT Suggested to check through the libsodium.a it self for the function with the strings command. It is present there.

unique siren
wicked flint
unique siren
# wicked flint It is there. So the the .a file should be the right one. Have other idea?

Try this, it should work I am not sure why it wouldn't:

g++ -shared -fPIC \
    -I"C:/WEB/NChat/app/headers" \
    -I"C:/WEB/NChat/app/headers/libsodium-win64/include" \
    -I"C:/cpp/global_libs/mariadb/install/include/mariadb" \
    "C:/WEB/NChat/app/handlers/user.cpp" \
    -L"C:/WEB/NChat/app/headers/libsodium-win64/lib" \
    -L"C:/cpp/global_libs/mariadb/install/lib/mariadb" \
    -lmariadbclient \
    -lws2_32 -lsecur32 -lcrypt32 -ladvapi32 -lshlwapi -lbcrypt \
    -lsodium \
    -o "C:/WEB/NChat/app/handlers/user.dll"
#

Otherwise you could do

nm libsodium.a | grep crypto_pwhash_str
unique siren
#

How very strange try forcing the lib in there

g++ -shared -fPIC \
    -I"C:/WEB/NChat/app/headers" \
    -I"C:/WEB/NChat/app/headers/libsodium-win64/include" \
    -I"C:/cpp/global_libs/mariadb/install/include/mariadb" \
    "C:/WEB/NChat/app/handlers/user.cpp" \
    -L"C:/cpp/global_libs/mariadb/install/lib/mariadb" \
    -lmariadbclient \
    -lws2_32 -lsecur32 -lcrypt32 -ladvapi32 -lshlwapi -lbcrypt \
    "C:/WEB/NChat/app/headers/libsodium-win64/lib/libsodium.a" \
    -o "C:/WEB/NChat/app/handlers/user.dll"
wicked flint
#

Still nothing...

wicked flint
wicked flint
#

Where is the issue.

unique siren
#

Unless g++ is having issues with that lib maybe, I am really not sure, if I were you and annoying as this is, I would just use WSL and install everything through the package maanger

#

Then it will save all this manual bollocks

wicked flint
unique siren
wicked flint
unique siren
#

Anywho, you should really avoid the pain which is non MSVC on windows, so on windows just stick with VS2022 and MSVC, it is the easiest options.
If you want to use g++ just use wsl where it is properly supported and you can get all the packages easily on it
Windows does not work well with these packages

wicked flint
#

I dont even have gcc on my pc

unique siren
#

Well you must have, when you install clang it doesn't install gcc

#

The ONLY place where g++ is actually clang is on apple mac where they hide it

wicked flint
# unique siren Well you must have, when you install clang it doesn't install gcc
C:\WEB\NChat>g++ --version
clang version 20.1.8 (https://github.com/llvm/llvm-project.git 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
Target: i686-w64-windows-gnu
Thread model: posix
InstalledDir: C:/cpp/LLVM/bin
Configuration file: C:/cpp/LLVM/bin/i686-w64-windows-gnu.cfg

C:\WEB\NChat>clang++ --version
clang version 20.1.8 (https://github.com/llvm/llvm-project.git 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
Target: i686-w64-windows-gnu
Thread model: posix
InstalledDir: C:/cpp/LLVM/bin
Configuration file: C:/cpp/LLVM/bin/i686-w64-windows-gnu.cfg
unique siren
#

Try: clang++ --target=x86_64-w64-windows-gnu

#

So:

clang++ --target=x86_64-w64-windows-gnu -shared -fPIC \
    -I"C:/WEB/NChat/app/headers" \
    -I"C:/WEB/NChat/app/headers/libsodium-win64/include" \
    -I"C:/cpp/global_libs/mariadb/install/include/mariadb" \
    "C:/WEB/NChat/app/handlers/user.cpp" \
    -L"C:/WEB/NChat/app/headers/libsodium-win64/lib" \
    -L"C:/cpp/global_libs/mariadb/install/lib/mariadb" \
    -lmariadbclient \
    -lws2_32 -lsecur32 -lcrypt32 -ladvapi32 -lshlwapi -lbcrypt \
    -lsodium \
    -o "C:/WEB/NChat/app/handlers/user.dll"
#

And then delete this weird ass compiler and install the proper 64 bit one

wicked flint
#

Yeah... Now I get the error linking the maridb connector, probably because it was built using the 32 bit target. I think I am fine from now, will try to fix further my self. thank you!

unique siren
#

Honestly, stop fooling around with all these manual paths, use WSL and it will install all the correct libs for you and the correct compiler

#

MinGW is dogshit

wicked flint
#

!solved