I am getting an error: 'vector' does not name a type with established source code. I crated a project with the NetBeans IDE and MinGW installed via Installation Manager mingw-get version 0.6.2-beta-20131004-1. The compiler command line is: gcc -c -g -Isrc -MMD -MP -MF "build/Debug/MinGW-Windows/src/basics.o.d" -o build/Debug/MinGW-Windows/src/basics.o src/basics.cpp
The offending code is:
using namespace std;
vector<string> listMaps() {
....
}
I added
#include <vector>
which fails, so I guess I need to install additional modules with mingw-get. How can I identify what is missing from the installation?
Related
I'm currently working on this project. I'm using cxxopts.hpp in order to parse cli options but since I added it I get some error that I now list how to reproduce:
Build the project
$ meson build
$ cd build
$ ninja
Everything good so far, it builds without any errors.
I can change anything other than test/vector.cpp and test/random.cpp (that are the places where I'm using cxxopts.hpp) and build with ninja without any problems.
Then when I edit test/vector.cpp or test/random.cpp and do ninja these error appears:
[1/4] Compiling C++ object test/random.p/random.cpp.o
FAILED: test/random.p/random.cpp.o
c++ -Itest/random.p -Itest -I../test -I../include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Wpedantic -O0 -g -MD -MQ test/random.p/random.cpp.o -MF test/random.p/random.cpp.o.d -o test/random.p/random.cpp.o -c ../test/random.cpp
In file included from ../include/cxxopts.hpp:43,
from ../test/random.cpp:6:
test/vector:1:1: error: stray ‘\177’ in program
1 | <U+007F>ELF<U+0002><U+0001><U+0001><U+0003><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0003><U+0000>><U+0000><U+0001><U+0000><U+0000><U+0000> F<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>#<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><90><91><U+0015><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>#<U+0000>8<U+0000><U+000D><U+0000>#<U+0000>(<U+0000>'<U+0000><U+0006><U+0000><U+0000><U+0000><U+0004><U+0000><U+0000><U+0000>#<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>#<U+0000><U+0000><U+0000><U+0000>...
(a very lengthy error up to 400 MB in a file)
Any idea on how to fix this or why this happens in the first place?
As pointed out by #KamilCuk in their comment, this error emerged from a name collision between the standard library #include <vector> and the binary vector I was creating from vector.cpp.
Changing the name of my binary solves the issue.
EDIT:
The desired behavior can be also achieved by setting the option implicit_include_directories to false like this:
vector = executable('vector', 'vector.cpp', include_directories: incdir, implicit_include_directories: false)
Build settings
Included #include <windows.h> and #include <Psapi.h> but I keep getting this error.
g++ -O3 -Wall -c -fmessage-length=0 -o main.o "..\\main.cpp"
..\main.cpp: In function 'int main()':
..\main.cpp:27:64: error: 'QueryFullProcessImageName' was not declared in this scope
if (QueryFullProcessImageName(hProcess, 0, buffer, &buffSize)) {
You were probably using classic MinGW, which is quite outdated.
Please use the more up to date MinGW-w64, which exists for both Windows 32-bit and 64-bit.
A recent version can be installed via MSYS2's package manager or you can get a standalone version from https://winlibs.com/.
I'm trying to compile a CUDA application with Nsight that compiles .cpp files to .o files then links the main application. I'm basing my build off the NVIDIA "Parallel for All" example Separate Compilation and Linking of CUDA C++ Device Code and its Makefile:
objects = main.o particle.o v3.o
all: $(objects)
nvcc -arch=sm_20 $(objects) -o app
%.o: %.cpp
nvcc -x cu -arch=sm_20 -I. -dc $< -o $#
clean:
rm -f *.o app
When I copy my code into a new directory and use that Makefile (adapted to my filenames and other flags, of course), everything works fine.
But I can't figure out how to get the same options into Eclipse and as such the build always fails with the following errors:
/usr/local/cuda-7.5/bin/nvcc -G -g -O0 -std=c++11 -gencode arch=compute_50,code=sm_50 -odir "src" -M -o "src/Object.d" "../src/Object.cpp"
/usr/local/cuda-7.5/bin/nvcc -G -g -O0 -std=c++11 --compile -x c++ -o "src/Object.o" "../src/Object.cpp"
../src/kernels.cu:31:12: error: ‘blockIdx’ was not declared in this scope
#... lots more "no one told me this was CUDA" errors
../src/Object.cpp:125:26: error: expected primary-expression before ‘<’ token
#... can't call CUDA kernels from cpp either ...
My project files' relevant includes are are:
Object.cpp:
#include "Object.h"
#include "kernels.cu"
main.cpp: (same error with fname as main.cu)
#include "Object.h"
kernels.cu:
#include "Object.h"
Object.h:
#include <cuda_runtime.h>
The code compiles fine with the custom makefile. The missing piece appears to be the -dc (device code) flag but I don't know how to enable it in Nsight Eclipse edition. I know I can create a Makefile project, but I'd really prefer to do it from within Eclipse so that all the introspection works right etc.
I solved the problem, though I still don't entirely understand it...
It seems that the -x c++ was the key flag, not -dc.
The default build settings of Nsight Eclipse work correctly when the files are renamed as follows:
Object.cpp Object.cu:
#include "Object.h"
#include "kernels.cuh"
main.cpp: (main.cu is also good)
#include "Object.h"
kernels.cu kernels.cuh:
#include "Object.h"
Object.h:
#include <cuda_runtime.h>
Apparently .cu files are compiled to .o files with -x cu (language CUDA) and then linked but .cpp files are compiled with language -x c++ and therefore do not see all of the CUDA markup. The main.cpp file has no actual CUDA in it so it doesn't matter.
Without renaming the kernels.cu to kernels.cuh build fails with multiple definition errors because it's compiled twice.
The current configuration appears to work, I hope this is helpful to someone. I really wish there was some clear documentation or settings on how file extensions affect build rules in Nsight...
So I have been trying to install DDD. I am on a Mac OS X 10.9(Mavericks) and I have the latest Xcode installed. Whenever I run my configure file the last thing I get is the following:
checking whether c++ accepts -g... yes
checking whether the C++ compiler (c++) compiles a simple program... no
configure: error: You must set the environment variable CXX to a working
C++ compiler. Also check the CXXFLAGS settings.
See the file 'config.log' for further diagnostics.
and whenever I check the config.log file I get:
configure:2684: c++ -o conftest -g -O2 conftest.C 1>&5
configure:2678:10: fatal error: 'iostream.h' file not found #include <iostream.h>
1 error generated.
configure: failed program was:
#line 2677 "configure"
#include "confdefs.h"
#include <iostream.h>
int main() {
cout << "hello, world!";
; return 0; }
I have downloaded the gcc from sourcefourge and installed gcc-4.9 again, but I still getting the same error. Anybody knows how to fix this or what the problem maybe?
It seems like you are compiling c++ program but you passing .c file to c++ compiler. You passing conftest.c file to c++ compiler, it has to be confest.cpp.
configure:2684: c++ -o conftest -g -O2 conftest.C 1>&5
This has to be
configure:2684: c++ -o conftest -g -O2 conftest.cpp 1>&5
And
fatal error: 'iostream.h' file not found #include <iostream.h>
1 error generated.
For above error change your code
to #included <iostream>
instead of #include <iostream.h>
Just open you configure file in DDD directory and add the following
`<iostream>
using namespace std;
`
and that should solve this error
I've written a very simple c++ function in main.cpp:
#include <iostream>
using namespace std;
int SomeCalculation(float x){
int decision = 0;
if (x > 1){
decision = 1;
}
return decision;
}
I'm now trying to compile this as a shared library using Boost.Python. For this I created decision.cpp:
#include <boost/python.hpp>
BOOST_PYTHON_MODULE(decision)
{
using namespace boost::python;
def("main", main);
}
Unfortunately I get the following error:
In file included from /usr/include/boost/python/detail/prefix.hpp:13:0,
from /usr/include/boost/python/args.hpp:8,
from /usr/include/boost/python.hpp:11,
from decision.cpp:1:
/usr/include/boost/python/detail/wrap_python.hpp:50:23: fatal error: pyconfig.h: File or folder does not exist.
compilation terminated.
Since I had no clue of where this file could be I did a simple sudo find / -name pyconfig.h, which found several pyconfig.h files. So I simply copied what to me seemed the most general version of the file, to the folder in which I'm working:
cp /usr/include/python2.7/pyconfig.h /home/kram/c++/cmod/pyconfig.h
Running my compile command again (g++ -fPIC -g -ggdb -c decision.cpp -o decision.so) gives me the same error as before though.
Does anybody know how I can solve this pyconfig.h dependency?
[edit] Added pieces of code
Try command:
g++ -g -shared -fPIC -I/usr/include/python2.7 decision.cpp -lpython2.7 -lboost_python -o decision.so