SpiderMonkey Link Error: FloatingPoint.h not found - c++

I'm very new to spiderMonkey and have followed this tutorial to get started (I'm using MAC OS X): https://developer.mozilla.org/en/docs/How_to_embed_the_JavaScript_engine
Every time I try to do the linking command in Step 6:
cl helloworld.cpp -link dist/lib/mozjs185-1.0.lib
I get the following 2 problems:
1) mozjs185-1.0.lib is not present in any directory (I've downloaded both the spiderMonkey and Mozilla source code)
2) Once I edit the path to point to the .lib file I do have I get the following error: FloatingPoint.h not found. However, I can find FloatingPoint.h on the system just at a different directory.
Could anyone give me a clue as to in which directory these header files should be? Or how to get the required .lib file? I've followed instructions on the mozilla development site meticulously and still can't get a hang of this.

After a few hours battling with this, I've managed to link properly by adding the hello world.cpp file in the build-release folder (as described in the Build Documentation; for more info see: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Build_Documentation).
From the terminal, I then cd into the build-release folder and type in the following command:
g++ -Idist/include -Ldist/bin -lmozjs185 helloworld.cpp -o helloworld
Unfortunately I am still getting this error:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/atomic:539:2: error: atomic is not implemented
I am pretty sure this has to do with the c++ compiler installed, and I still have to find a workaround, but at least it's properly linking now!

Related

"unsupported/Eigen/CXX11/Tensor: No such file or directory" while working with TensorFlow

I'm trying to use tensorflow as a external library in my C++ application (mainly following this tutorial). What I done so far:
I have cloned the tensorflow reporitory (let's say, that the repo root dir is $TENSORFLOW)
Run /.configure (which all settings default, so no CUDA, no OpenCL etc.).
Build shared library with bazel build -c /opt //tensorflow:libtensorflow_cc.so (build completed successfully)
Now I'm trying to #include "tensorflow/core/public/session.h". But after including it (and adding $TENSORFLOW and $TENSORFLOW/bazel-genfiles to include path), I'm receiving error:
$TENSORFLOW/tensorflow/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1:42:
fatal error: unsupported/Eigen/CXX11/Tensor: No such file or directory
There is a github issue created for similar problem, but it's marked as closed without any solution provided. Also I tried with master branch as well as v.1.4.0 release.
Do you happen to know, what could cause this kind of problem and how to deal with it?
I (and many others) agonized over the same problem. It probably can be solved using bazel but I don't know that tool well enough and now I solve this using make. The source of confusion is that a file named Tensor is included and it itself includes a file named Tensor, which has caused some people to wrongly conclude Tensor is including itself.
If you built and installed the python .whl file there will be a tensorflow directory in dist-packages and an include directory below that, e.g. on my system:
/usr/local/lib/python2.7/dist-packages/tensorflow/include
From the include directory
find . -type f -name 'Tensor' -print
./third_party/eigen3/unsupported/Eigen/CXX11/Tensor
./external/eigen_archive/unsupported/Eigen/CXX11/Tensor
The first one has
#include "unsupported/Eigen/CXX11/Tensor"
and the file that should satisfy this is the second one.
So to compile session.cc that includes session.h, the following will work
INC_TENS1=/usr/local/lib/python2.7/dist-packages/tensorflow/include/
INC_TENS2=${INC_TENS1}external/eigen_archive/
gcc -c -std=c++11 -I $INC_TENS1 -I $INC_TENS2 session.cc
I've seen claims that you must build apps from the tensorflow tree and you must use bazel. However, I believe all the header files you need are in dist-packages/tensorflow/include and at least for starters you can construct makefile or cmake projects.
Slightly off-topic, but I had the same error with a C++ project using opencv-4.5.5 and compiled with Visual Studio (no problem with opencv-4.3.0, and no problem with MinGW).
To make it work, I had to add to my root CMakeLists.txt:
add_definitions(-DOPENCV_DISABLE_EIGEN_TENSOR_SUPPORT)
If that can help someone...
the problem was actually in the relative path of the header file taken in the Tensor file.
installed path for Tensor is /usr/include/eigen3/unsupported/Eigen/CXX11/Tensor
but mentioned in the Tensor file is "unsupported/Eigen/CXX11/Tensor"
So there should be an entry upto /usr/include/eigen3/ in the project path to run this correctly so that it can be used.

Can't find files of cxxtest when I'm trying to run compiled file

I started writing a small project on C++. I just wanted to develop using TDD because in Java I always do that. I faced a problem that using any libraries and so on is a bit easier in Java IDEs and tools (like maven and so on). But it's not exactly topic I'm talking about.
I found cxxtest framework and decided to add one into my project.
I added the latest version of sources exactly into my test package in project, then I write simple test, and then I ran preprocessor (using python) by "python cxxtestgen --error-printer -o ../runner.cpp ../../testSample.h" from cxxtest-4.4/bin folder.
After that I got the runner.cpp file into cxxtest-4.4 folder. I tried to run that using command "g++ -o runner runner.cpp" in suitable place...and got the following message:
bash-3.2$ g++ -o runner runner.cpp
runner.cpp:8:10: error: 'cxxtest/TestListener.h' file not found with <angled> include; use "quotes" instead
#include <cxxtest/TestListener.h>
^~~~~~~~~~~~~~~~~~~~~~~~
"cxxtest/TestListener.h"
In file included from runner.cpp:8:
./cxxtest/TestListener.h:24:10: fatal error: 'cxxtest/Descriptions.h' file not found
#include <cxxtest/Descriptions.h>
^~~~~~~~~~~~~~~~~~~~~~~~
Here I put my project structure:
The project structure
It seems very strange because I've never seen the same troubles before. And it's not able to find same issues.
So, would be great if somebody told my even right direction to fix this problem. Let me know If you need something else to make more clear understanding of this problem (code, any technical info, etc)
Some info: I'm using CLion on macOS, it means I have CMake (version 3.6 at least), I have both perl and python on my mac. Project with C++14 language version.

Cannot open source file "bits/c++config.h" error with icpc

I am trying to compile a program on a 64-bit machine with icpc. Unfortunately, I get an error message of catastrophic error: cannot open source file "bits/c++config.h". I have adopded some advice from here but with no success. Also, I do not forget to run source /opt/intel/bin/compilervars.sh intel64 before hand and I'm on Ubuntu 13.10 in case this is important.
First, find the missing file:
find /usr -name c++config.h
(Headers are in /usr, most of the time.) Then, add its top dir to the include path of your compilation command, so the compiler will find "bits/c++config.h", using the -I option. A similar question was already asked on SO, BTW: Missing include "bits/c++config.h" when cross compiling 64 bit program on 32 bit in Ubuntu.
For some reason the icpc compiler doesn't parse the following directory. You can set the following variable; replace 4.8 by your g++ version
export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/include/x86_64-linux-gnu/c++/4.8

Trouble to generate header file for JNI

I compiled HelloWorld.c successfully. I changed to the directory where HelloWorld.class is.
And I typed javah -jni HelloWorld in Terminal to get header file. I have the following error message. What is the problem? I am developing Android app using Mac OSX.
error: cannot access HelloWorld
bad class file: ./HelloWorld.class
class file contains wrong class: Test.HelloWorld
Please remove or make sure it appears in the correct subdirectory of the classpath.
com.sun.tools.javac.util.Abort
javadoc: error - fatal error
2 errors
I guess that your HelloWorld.class is located in a subfolder Test. You are not expected to be INSIDE that folder but in the ROOT folder for your compiled package(s). So go out of that Test folder and try again javah -jni Test.HelloWorld
BTW i don't understand how you could "compile your HelloWorld.c succesfuly" if you don't even have the header yet. But i am answering what have been asked.

Can't get cygwin to compile C++ Boost libraries

I'm trying to get up and running with Boost, so I'm trying to compile the simple example problem from Boost's "Getting Started" page. I've had two issues, and I'm not sure they're related (I'm better than a novice, but not by much) but maybe they're related...
1st issue: the "tar --bzip2 -xf /path/to/boost_1_49_0.tar.bz2" command didn't work (yes, I put the correct path in, but it gave me some errors, I forget what they were) so I used "tar -xjvf " from the directory where boost_1_49_0.tar.bz2 was located. That de-compressed the zip file and I proceeded with the example...
2nd issue: The example.cpp file will not compile, the first statement in the code is #include "boost/lambda/lambda.hpp" but then for every header file lambda.hpp is trying access, there's a "No such file or directory" compile error. For example, here are two (of the six, and I get errors for all 6) header files within lambda.hpp and the errors displayed by the cygwin compiler:
boost/lambda/lambda.hpp:14:33: boost/lambda/core.hpp: No such file or directory
boost/lambda/lambda.hpp:21:52: boost/lambda/detail/operator_actions.hpp: No such file or directory
If it helps, this is the command I'm running to compile (I generally create the executable in a separate -o command):
g++ -c example.cpp
Why can't the system find these? I added the installed directory (path/to/boost_1_49_0) to the PATH variable before I started so I know that's no it. Thanks for any advice...
(I've looked on stackoverflow and there were similar issues, but no solutions that worked)
It looks like you've already solved the first issue: namely, that you must specify the -j flag on tar to untar a bzip2'd file.
For the second issue, you need to specify boost on your include path, either by specifying it with the -I command line option or via the CPLUS_INCLUDE_PATH environment variable.