I have been trying to set up fly-make on my system. But it hasn't been working.
I have a C++ file called advancedFunctions.cpp and a have a Makefile in the directory where my .cpp file is housed. My Makefile contains this:
check-syntax:
g++ -o nul -S $(CHK_SOURCES)
advancedFunctions:
g++ -o advancedFunctions advancedFunctions.cpp
Whenever I invoke flymake via M-x flymake, it give this error:
Flymake: Configuration Error has occurred while running (make -s -C ./ CHK_SOURCES=advancedFunctions_flymake.cpp SYNTAX_CHECK_MODE=1 check-syntax). Flymake will be switched off.
What can I do about this? Hints, please.
Related
I'm trying to compile C++ on Windows.
The command needed to compile on Linux is:
g++ -O3 -Wall -shared -std=c++11 -fPIC `python -m pybind11 --includes` EO_functions_bipartite.cpp -o extremal_bi.so
I installed MinGW but when I try to compile I get the following error:
g++.exe: error: python: No such file or directory
g++.exe: error: pybind11: No such file or directory
g++.exe: error: unrecognized command line option '-m'
g++.exe: error: unrecognized command line option '--includes EO_functions_bipartite.cpp'
g++.exe: fatal error: no input files
compilation terminated.
Assuming you have python in your path.
The backtick escape thing that embeds the python -m pybind11 --includes command within the g++ doesn't work on cmd.exe in Windows.
Run the python -m pybind11 --includes command on its own line in the cmd shell. Take the output of that command and substitute in into the g++ command. It should be a bunch of -I include params.
So if the output of the python command is this:
-IC:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\Include -IC:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pybind11\include
Expand your g++ command to be this:
g++ -O3 -Wall -shared -std=c++11 -fPIC "-IC:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\Include" -IC:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pybind11\include EO_functions_bipartite.cpp -o extremal_bi.so
Notice the quotes I put around the first include directory because it has a space in its path.
The easiest way to start on native Windows if you have a Linux background is to install MSYS2 shell with MinGW-w64. This will provide an actual bash that allows you to run commands almost exactly the same way as on Linux, including support for backticks like in the case of your issue.
Though I would always recommend using $( ... ) instead of backticks, as this allows nesting.
Note that MinGW-w64 also exists on Windows to allow cross-building for Windows from Linux, but that may be a bit more difficult if you have never done any cross-building before.
Also -shared ... -o extremal_bi.so in your command should be replaced with -shared ... -o extremal_bi.dll -Wl,--out-implib,libextremal_bi.dll.a as .so files don't exist on Windows as Windows uses .dll files for shared libraries and the compiler uses .dll.a files as library objects for them.
Finally on Windows you need to tell the compiler or linker which symbols you will be exporting by either writing a libextremal_bi.def starting with the line EXPORTS followed all the symbols you want to be exported and include -def libextremal_bi.def in the link command, or using __declspec(dllexport)/__declspec(dllimport) when defining those symbols, which may be a bit complexer as it requires some conditional defines to determine if the code is being compiled for Windows and if it's during the actual build process of the shared library (__declspec(dllexport)) or code that uses it (__declspec(dllimport)). There is also another method to export all symbols, but that's a dirty method that may more easily cause symbol conflicts.
I’m new to alpine linux, and I’ve been trying to use it to run and compile C++ code, but I can’t get it to run the code.
First, I put the code in the opt folder, than I did this:
cd / → cd opt → clang++ -S -emit-llvm myFile.cpp
That created myFile in the opt folder, then I tried to use
sh myFile
To run the code, but it said “no such file or directory found,” If I do sh myFile.cpp, I get a few errors.
What am I doing wrong here?
Some of the packages I have installed are build-base, and clang.
By default, the result of clang (clang++ as well) is saved to a.out file, so you may run ./a.out or sh a.out. If you want to change output, use -o <filename> in clang command
If I write this code and saved as a.cpp at ~/Desktop
#include <memory>
int main(){}
then input to bash:
cd /usr/bin
g++ -g ~/Desktop/a.cpp -o ~/Desktop/a
then the g++ will output plenty of messy code of errors.
I have found the reason is because it don't have authority to link XX.so library.
But if I add a 'sudo' , or set CWD to the path owned by user, g++ will work properly, as follows:
sudo g++ -g ~/Desktop/a.cpp -o ~/Desktop/a
or
cd ~/Desktop
g++ -g ~/Desktop/a.cpp -o ~/Desktop/a
Why do this happen? or how can I fix this?
You don't want to generate code directly in /usr/bin.
You generate your code in your user folder, maybe create a sub-directory called cppwork or something like that.
cd
mkdir cppwork
cd cppwork
g++ -g a.cpp -o a
Once you compiled in your directory, then you copy the file using install which will also take care of stripping the debug if any (i.e. the -g says to keep debug info—stripping is not mandatory).
sudo install -s a /usr/bin/a
As you can see, the place where I use sudo is with the install command.
That being said, I never use those directly. Now a day, I use cmake which means everything works automatically. But that would be a different discussion.
Thanks for every one. I have found the reason. It's because there is an executable program named 'array' in /usr/bin. And when CWD is /usr/bin, the compiler regard this 'array' as the c++ header <array>, so compiling error.
Then I need to find out why the compiler includes /usr/bin by mistake.
I'm new to C++, I am trying to compile gtest with Cygwin. I have installed the GNU g++ compiler which works fine. I ran the following command on Cygwin:
g++ -I /cygdrive/c/devel/cpp/gtest/include -I /cygdrive/c/devel/cpp/gtest -pthread -c /cygdrive/c/devel/cpp/gtest/googletest/src/gtest-all.cc
/cygdrive/c/devel/cpp/gtest/googletest/src/gtest-all.cc:39:25: fatal error: gtest/gtest.h: No such file or directory
compilation terminated.
All the files seem to be in place, however the error does not go, any ideas why?
It looks like you have provided space between -I and path.
There should not be any space between -I and corresponding path.
It should be like
g++ -I/cygdrive/c/devel/cpp/gtest/include -I/cygdrive/c/devel/cpp/gtes..
Check it.
I'm currently running ubuntu 13.10 with codeblocks and when I try to build it comes up with this message:
g++ -c /home/rhys/Documents/Progamming/c++/Class_private/main.cpp -o /home/rhys/Documents/Progamming/c++/Class_private/main.o
/bin/sh: 0: Can't open g++ -c /home/rhys/Documents/Progamming/c++/Class_private/main.cpp -o /home/rhys/Documents/Progamming /c++/Class_private/main.o
Process terminated with status 127 (0 minutes, 0 seconds)
0 errors, 0 warnings (0 minutes, 0 seconds)
It used to work fine but it does not work now, I have downloaded the build-essential, then the gcc complier which it is set to in the settings.
Can anyone help??
check "Settings -> Environment -> General settings -> Shell to run commands in:" and make sure it says "/bin/sh -c" you must have the -c argument. Either this or it could a file path problem with the compiler or source files themselves.
I think you must set the access for your files and/or your whole working directory. So go there, and change permission with chmod:
cd /home/rhys/Documents/Progamming/c++/Class_private/
chmod 755 *
If this not works maybe you should check if g++ is accessible. Run:
g++ --version
See if it prints the information or another error.
Another solution could be to open Code::Blocks as a superuser and then try again as you normally did.