Linking error while bulding code with WASM - linker

I am building C++ code using wasm(emsdk version 3.1.3) and cmake(3.15.5) and am getting the following error: -
wasm-ld: error: /Users/...somePath.../boost/boost_thread/libboost_thread.a(thread.obj): undefined symbol: __wasm_lpad_context
Anyone has any idea how to fix this?

I was able to find the answer. You need to add the flag -fwasm-exceptions to your list of compiler and linker flags.

Related

fatal error: sodium.h: No such file or directory

Thank you #stark I was unaware you had to link the directory as part of #include. This part is now working though when I include.
(sodium_init() < 0)
{
printf("Sodium could not be initialized");
return 1;
}
I now receive the error "undefined reference to 'sodium_init'.
I have tried adding -lsodium to the compile command (gcc -g -lsodium file1.c file2.c file1.h -o file1.c.exe) which gives the error.
"cannot find -lsodium collect2.exe: error: ld returned 1 exit status"
Through further searching I believe I need to tell the compiler where to find -lsodium though cannot find out how.
-- below has been solved using #stark advice --
I have been trying to get the sodium library working for the last 3 days. I have followed the instillation instructions here(https://libsodium.gitbook.io/doc/installation) which all appear to have completed successfully, but still receive the error.
I then found information suggesting I have not linked Visual Studio (community edition) to the library location.
I have attempted to follow the instructions here(https://www.learncpp.com/cpp-tutorial/a2-using-libraries-with-visual-studio-2005-express/) but cannot see "VC++ Directories". I have tried several other sets of directions with the same outcome.
Is anyone able to help getting the sodium library working so I can get access to the RtlGenRandom() function?

C - Undefined reference to 'ceil' in Netbeans

I have problem which was mentioned here multiple times, but i still cant find out how to relsove it.
I want use ceil() function in NetBeans-IDE, but still getting error Undefined reference to 'ceil'. I tried add -lm into gcc compiler by project properties but no success.
Can someone help me how to solve this specific problem?

Forcing compile time error for "undefined symbol" in scons

I am having a problem where I get this error: "undefined symbol: someVar" at runtime. I would like to get that error at link time.
I would like to force a link error similar to this issue:
Easy check for unresolved symbols in shared libraries?
I am using scons, so I am looking for an scons specific answer.
My scons rule looks like this:
def create_objs(SRCS):
return [env.Object(src) for src in SRCS]
object_mylib = ['mylib.c'
,'one.c'
,'two.c'
]
env.SharedLibrary('#/lib/mylib', create_objs(object_mylib))
I found this issue for adding linker flags in scons:
How do I add --whole-archive linker option in scons?
A) Is my best option to pattern a solution after those two issues to add the proper flag?
B) Is there a better way?
It seems that some doubt that I am getting this error at runtime, so I am adding this detail:
I get this error:
could not load /somepath/libmylib.so for /somepath/libmylib.so: undefined symbol: someVar
On this code:
char *libFile = "/somepath/libmylib.so";
Handle = dlopen(libFile, RTLD_LAZY);
if (!Handle)
{
printf("could not load %s for %s", libFile, dlerror());
}
during runtime.
My backup plan is to write a small program that does the dlopen and add that to the SConscript.
Here is the answer I (the OP) came up with:
Add
env.Append(LINKFLAGS=['-Wl,-z,defs'])
to SConstruct
Now this command runs:
gcc -o lib/libmylib.so -Wl,-z,defs -shared build/mylib.o build/one.o build/two.o
Which outputs this error:
build/one.o: In function `somefunc':
/home/.../src/one.c:34: undefined reference to `someVar'
This works for me. I will wait while before accepting this answer to see if anyone comes up with a better technique or improvements to this technique.

Error: L6218E: Undefined symbol __main (referred from anon$$obj.o)

I am trying to compile using ARM Compiler. I wrote a simple program.
Where the C:\Source_Codes\2250_sdk\sdkfiles2delivery.....\arm_rvct22\include\windows\ contains all the include files.
Problem : i m facing some unusual linker error
===========================
main.c: 1 warning, 0 errors
Warning: L6310W: Unable to find ARM libraries.
Error: L6218E: Undefined symbol __0printf (referred from main.o).
Error: L6218E: Undefined symbol __main (referred from anon$$obj.o).
Finished: 0 information, 1 warning and 2 error messages.
====================================
Please help me in this
Thanks
regards
Sobin Thomas
With the Arm compiler setting check the Compiler flags and the Linker flags. Try using --verbose to find which Library is missing. Also check if in case you are using environment variable check if the path is correct.
Primary Reasons for this failure reported.
1. Library not found or missing or path not correct
2. Compiling of c code as C++ results in symbol not found, identify the API and try using
extern c{};
Try to add a .c file to project: e. g. if you're working on timers, add stm32f4xx_tim.c to User folder and add it to your project directory.

ld error while building GD library for Haskell on Windows

When installing the Haskell GD package through cabal, on Windows (using MinGW), I get the following warnings:
Warning: resolving _gdImagePtrDestroyIfNotNull by linking to _gdImagePtrDestroyIfNotNull#4
Warning: resolving _gdImageCopyRotated90 by linking to _gdImageCopyRotated#36
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Note that these are precisely the functions defined in gd-extras.
Then, when actually compiling a Haskell program which uses gd, I get the following errors:
Linking Main.exe ...
[...]\cabal\gd-3000.7.3\ghc-7.4.1/libHSgd-3000.7.3.a(Internal.o):fake:(.text+0x2211):undefined reference to 'gdImageCopyRotated90'
[...]\cabal\gd-3000.7.3\ghc-7.4.1/libHSgd-3000.7.3.a(Internal.o):fake:(.text+0x500a):undefined reference to 'gdImagePtrDestroyIfNotNull'
[...]
collect2: ld returned 1 exit status
I'm unable to figure out how to fix this — it's already taken me ages to get to this point, as I've had many more issues trying to get it working, but this seems like the final hurdle. I have tried enabling/disabling stdcall fixup, and also changing in which file these functions are defined (as gd-extras seemed to be a potential issue), but that hasn't adressed the issues.
Thanks for any help.
You need to pass explicit linker flags to ghc, pointing to the library. The Haskell GD library is automatically linked, but the dll will not be linked as well unless you tell ghc about it. The stdcall-fixup errors are a red herring here.

Resources