Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emscripten build error #8

Open
rdroe opened this issue Aug 18, 2019 · 15 comments · May be fixed by OGStudio/openscenegraph-cross-platform-guide-application#1
Open

Emscripten build error #8

rdroe opened this issue Aug 18, 2019 · 15 comments · May be fixed by OGStudio/openscenegraph-cross-platform-guide-application#1

Comments

@rdroe
Copy link

rdroe commented Aug 18, 2019

Thanks for the great tutorials. I've run through a couple with success.
However, walking through your Emscripten, I get a build error:

[ 80%] Building CXX object /home/davo/sites/OpenSceneGraph/build/Emscripten/src/osgAnimation/CMakeFiles/osgAnimation.dir/StackedTransform.cpp.o
[ 80%] Building CXX object /home/davo/sites/OpenSceneGraph/build/Emscripten/src/osgUI/CMakeFiles/osgUI.dir/Validator.cpp.o
[ 81%] Linking CXX executable sample-ems.html
shared:ERROR: emcc: cannot find library "nul" (`-s ERROR_ON_MISSING_LIBRARIES=0` to disable this error)
make[2]: *** [CMakeFiles/sample-ems.dir/build.make:100: sample-ems.html] Error 1
make[1]: *** [CMakeFiles/Makefile2:81: CMakeFiles/sample-ems.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 81%] Building CXX object /home/davo/sites/OpenSceneGraph/build/Emscripten/src/osgManipulator/CMakeFiles/osgManipulator.dir/Translate2DDragger.cpp.o
[ 81%] Building CXX object /home/davo/sites/OpenSceneGraph/build/Emscripten/src/osgAnimation/CMakeFiles/osgAnimation.dir/StackedTranslateElement.cpp.o
[ 81%] Building CXX object /home/davo/sites/OpenSceneGraph/build/Emscripten/src/osgWrappers/serializers/osgSim/CMakeFiles/osgdb_serializers_osgsim.dir/DirectionalSector.cpp.o
...
[ 91%] Linking CXX static library ../../../lib/libosgdb_ive.a
[ 91%] Built target osgdb_ive
make: *** [Makefile:130: all] Error 2

I followed the instructions exactly.
This is on Ubuntu 19.04 but same on OSX Mojave.

When I had entered emsdk activate latest, some of the output was

Set the following tools as active:
   releases-fastcomp-7b4b328af02eafbc857b8ca1e3d9b12dddc56ef7-64bit
   node-8.9.1-64bit

Thanks again! The tutorials were really helpful for other systems.

@kornerr
Copy link
Contributor

kornerr commented Aug 26, 2019

Emscripten got updates since the time of the guide publication. Unfortunately, rarely do developers care about stability, so they change the behavior of software sigh.

To fix the issue, try to update openscenegraph-cross-platform-guide-application/web/CMakeLists.txt by replacing the following line:

SET(USE_SDL2 "-s USE_SDL=2")

with:

SET(USE_SDL2 "-s USE_SDL=2 -s ERROR_ON_MISSING_LIBRARIES=0")

Please, let me know if it works for you: I'll update the guide's code.

@rdroe
Copy link
Author

rdroe commented Aug 27, 2019

Thanks! This time tomorrow at latest, I'll let you know.

@rdroe
Copy link
Author

rdroe commented Aug 28, 2019

The suggestion seems to have gotten me past that error. The next, I'm guessing, is something similar. Compiler suggests "ERROR_ON_UNDEFINED_SYMBOLS=0".

I'm getting familiar with CMake, but not exactly sure where to put this.

I believe the issue is documented here where one of Emscripten's major ported libraries encountered it: https://git.sprintf.io/emscripten-ports/emscripten/commit/feb5be841fb973f1ac8e29d853e22e04d1cdab26

Any suggestions welcome; putting it in the CMakeLists.txt in the /web project did not apparently work. I am retrying in a new build directory.

Part of the actual error message:

[ 95%] Building CXX object /Users/robertroe/sites/OpenSceneGraph/build/Emscripten/src/osgWrappers/serializers/osgAnimation/CMakeFiles/osgdb_serializers_osganimation.dir/UpdateMatrixTransform.cpp.o
[ 95%] Building CXX object /Users/robertroe/sites/OpenSceneGraph/build/Emscripten/src/osgWrappers/serializers/osgAnimation/CMakeFiles/osgdb_serializers_osganimation.dir/UpdateMatrixfUniform.cpp.o
error: undefined symbol: pthread_attr_getstacksize
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
error: undefined symbol: pthread_testcancel
Error: Aborting compilation due to previous errors

@kornerr
Copy link
Contributor

kornerr commented Sep 2, 2019

@rdroe, try to use

SET(USE_SDL2 "-s USE_SDL=2 -s ERROR_ON_MISSING_LIBRARIES=0 -s ERROR_ON_UNDEFINED_SYMBOLS=0")

Let me know if it works

@rdroe
Copy link
Author

rdroe commented Sep 5, 2019

@kornerr
Seems to work. Seriously, thanks!!!
I'm forking the repo to make a PR, in case it's helpful.

@kornerr
Copy link
Contributor

kornerr commented Sep 5, 2019

Glad to hear that!

Could you please then rename USE_SDL2 into something like FLAGS in that PR? That would help us keep that variable "flexible".

@For-thewin
Copy link

I meet the same probelm. but it doesn't work; There is the error.
g++.exe: error: USE_SDL=2: No such file or directory
g++.exe: error: ERROR_ON_MISSING_LIBRARIES=0: No such file or directory

@rdroe
Copy link
Author

rdroe commented Nov 13, 2019

That definitely worked for Emscripten compilation (I was running on osx and linux).
The way to implement is not via command line, but to change the file CMakeLists.txt in the project you're trying to compile.

Also, make sure you're following the g++ project's instructions very closely. The error message looks unrelated to my problem.

If you reach the error I described, see https://github.com/OGStudio/openscenegraph-cross-platform-guide-application/pull/1/files; I'd do something like this, but not in the Emscripten project; rather the same file but in whichever project you're compiling.

@kornerr, I made the update you last requested: https://github.com/OGStudio/openscenegraph-cross-platform-guide-application/pull/1/files seems to work.

@kornerr
Copy link
Contributor

kornerr commented Nov 14, 2019

@rdroe, thanks, I'll merge the changes when I have time. Not sure if it's going to be soon enough, though.

@rdroe
Copy link
Author

rdroe commented Nov 14, 2019

@kornerr no rush for me, thanks

@radu022003
Copy link

radu022003 commented Jun 4, 2020

is this project currently succesfully compilable? i have also tried to make it work and i am facing the same error using the latest emscripten version on ubuntu 18.04.
as for the ERROR_ON_MISSING_LIBRARIES, according to documentation it is always on, so it shouldn't make any difference by setting it to zero.
I have a question though, is there any possibility to include the osg in Qt for WebAssembly?

I have tried to use the precompiled static libaries from here: https://github.com/MozillaReality/OpenSceneGraph/releases/tag/OpenSceneGraph-3.7.0-wasm+mozilla-gltf
but i couldn't successfully build it because a lot of errors related to undefined symbols from OSG.
I have also compiled the openscenegraph latest version for emscripten successfully and included it in Qt for Webassembly but i got the same errors.

@radu022003
Copy link

in order to make it work i added the followings in CMakeLists.txt (openscenegraph-cross-platform-guide-application/web), then executed the cmake command, then removed the -lnul inside the generated file inside sample-ems/CMakeFiles/sample-ems.dir/linklibs.rsp, then executed make command

@kornerr
Copy link
Contributor

kornerr commented Jun 5, 2020

in order to make it work i added the followings in CMakeLists.txt (openscenegraph-cross-platform-guide-application/web), then executed the cmake command, then removed the -lnul inside the generated file inside sample-ems/CMakeFiles/sample-ems.dir/linklibs.rsp, then executed make command

So, it now works for you, right?

@radu022003
Copy link

radu022003 commented Jun 5, 2020

Yes, i am able to build and run the application.
Here is what i added to CMakeFiles.txt and i forgot to add:
SET(FLAGS "-s USE_SDL=2 -s ERROR_ON_UNDEFINED_SYMBOLS=0")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${FLAGS}" CACHE STRING "Use SDL2" FORCE)
Actually I took it from pull request and removed the ERROR_ON_MISSING_LIBRARIES
Edit: I have to say that I was able to compile it using emsdk version 1.39.16, with version 1.38.27 (the one that Qt is build with) i still could not successfully build it.

But my aim is to make it work within Qt for Webassembly

@Davidobot
Copy link

I'm having a similar issue compiling on MacOS 10.15.5

I get a weird -lnul flag that appears in my linklib.rsp. It can't find the library when building initially, but if I just remove the flag, it compiles successfully. I assume nul is just a missing library name or something similar. Is there a way of preventing such behaviour?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants