I want build my c++ project with ISO c++ 98 but when I build I have this in console :
Info: Internal Builder is used for build
g++ -std=c++98 -O0 -g3 -Wall -c -fmessage-length=0 -o "src\ProvaISO98.o" "..\src\ProvaISO98.cpp"
In file included from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\postypes.h:40:0,
from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\iosfwd:40,
from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:38,
from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from ..\src\ProvaISO98.cpp:9:
d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\cwchar:164:11: error: '::vfwscanf' has not been declared
using ::vfwscanf;
^~~~~~~~
d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\cwchar:170:11: error: '::vswscanf' has not been declared
using ::vswscanf;
^~~~~~~~
d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\cwchar:174:11: error: '::vwscanf' has not been declared
using ::vwscanf;
^~~~~~~
d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\cwchar:191:11: error: '::wcstof' has not been declared
using ::wcstof;
^~~~~~
In file included from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\locale_facets.h:39:0,
from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_ios.h:37,
from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:44,
from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from ..\src\ProvaISO98.cpp:9:
d:\programmi\mingw\lib\gcc\mingw32\6.3.0\include\c++\cwctype:89:11: error: '::iswblank' has not been declared
using ::iswblank;
With ISO c++ 11 I haven't problem. Maybe I must change option -std=c++98 in -std=gnu++98 but I don't known how to do this.
Related
I'm trying to build the following example using Eclipse in OS X 10.8:
//============================================================================
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
if( argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the file
if(! image.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", image ); // Show our image inside it.
waitKey(0); // Wait for a keystroke in the window
return 0;
}
but getting this result:
**** Build of configuration Debug for project cvTesting ****
make all
Building file: ../src/cvTesting.cpp
Invoking: GCC C++ Compiler
g++ -I/opt/local/include/opencv -I/opt/local/include/opencv2 -I/opt/local/include/opencv2/core/ - I/opt/local/include/opencv2/highgui/ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/cvTesting.d" -MT"src/cvTesting.d" -o "src/cvTesting.o" "../src/cvTesting.cpp"
../src/cvTesting.cpp:9:33: warning: opencv2/core/core.hpp: No such file or directory
../src/cvTesting.cpp:10:39: warning: opencv2/highgui/highgui.hpp: No such file or directory
../src/cvTesting.cpp:13: error: 'cv' is not a namespace-name
../src/cvTesting.cpp:13: error: expected namespace-name before ';' token
../src/cvTesting.cpp: In function 'int main(int, char**)':
../src/cvTesting.cpp:24: error: 'Mat' was not declared in this scope
../src/cvTesting.cpp:24: error: expected `;' before 'image'
../src/cvTesting.cpp:25: error: 'image' was not declared in this scope
../src/cvTesting.cpp:25: error: 'CV_LOAD_IMAGE_COLOR' was not declared in this scope
../src/cvTesting.cpp:25: error: 'imread' was not declared in this scope
../src/cvTesting.cpp:33: error: 'CV_WINDOW_AUTOSIZE' was not declared in this scope
../src/cvTesting.cpp:33: error: 'namedWindow' was not declared in this scope
../src/cvTesting.cpp:34: error: 'imshow' was not declared in this scope
../src/cvTesting.cpp:36: error: 'waitKey' was not declared in this scope
make: *** [src/cvTesting.o] Error 1
**** Build Finished ****
I have opencv installed such that pkg-config reports the following:
$ pkg-config opencv --cflags
-I/opt/local/include/opencv -I/opt/local/include
and
$ pkg-config --libs opencv
/opt/local/lib/libopencv_calib3d.dylib /opt/local/lib/libopencv_contrib.dylib /opt/local/lib/libopencv_core.dylib /opt/local/lib/libopencv_features2d.dylib /opt/local/lib/libopencv_flann.dylib /opt/local/lib/libopencv_gpu.dylib /opt/local/lib/libopencv_highgui.dylib /opt/local/lib/libopencv_imgproc.dylib /opt/local/lib/libopencv_legacy.dylib /opt/local/lib/libopencv_ml.dylib /opt/local/lib/libopencv_nonfree.dylib /opt/local/lib/libopencv_objdetect.dylib /opt/local/lib/libopencv_photo.dylib /opt/local/lib/libopencv_stitching.dylib /opt/local/lib/libopencv_ts.dylib /opt/local/lib/libopencv_video.dylib /opt/local/lib/libopencv_videostab.dylib
and within Eclipse, in the project properties I have, C/C++ Build -> Settings -> GCC C++ Compiler "All options" set to:
-I/opt/local/include/opencv -I/opt/local/include/opencv2 -O0 -g3 -Wall -c -fmessage-length=0
and the C/C++ Build -> Settings -> MacOS X C++ Linker -> "All options" is set to:
-L/opt/local/lib
I also have the following libraries (-l) listed in C/C++ Build -> Settings -> MacOS X C++ Linker -> Libraries:
opencv_core
opencv_imgproc
opencv_highgui
opencv_ml
opencv_video
opencv_features2d
opencv_calib3d
opencv_objdetect
opencv_contrib
opencv_legacy
opencv_flann
I am able to build this same example in Ubuntu, just not OS X. Can anyone help explain the setup for the paths used by eclipse in OS X, for opencv?
As you can see in the compiler output:
../src/cvTesting.cpp:9:33: warning: opencv2/core/core.hpp: No such file or directory
../src/cvTesting.cpp:10:39: warning: opencv2/highgui/highgui.hpp: No such file or directory
Eclipse can't find core.hpp and highgui.hpp files. Are you sure that those files are in these locations?
Also you may try to use core.h and highgui.h instead of *.hpp files.
After a lot more more research on the topic, and working through various options, I found the best approach to be using Xcode rather than Eclipse for the IDE while in OS X.
The information I used to get Xcode setup and working correctly is in the Answer posted here:
Compile OpenCV (2.3.1+) for OS X Lion / Mountain Lion with Xcode
Prior to doing this though, I went back through the Mac OS X OpenCV Port instructions found here:
http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port
Hope this helps others trying to use OpenCV with a modern IDE in OS X...
-Walt
I am trying to get started using Rccp and decided to use Eclipse as a development environment since I already use StatEt for R. I am having trouble getting even a simple program to compile and run though, and would appreciate some help!
Briefly I tried to follow the instructions on the blog: http://blog.fellstat.com/?p=170 exactly for setting up Rcpp, RInside and Eclipse, and for the example program. I am running on Mountain Lion, and installed g++ using the command line options in XCode. I think I've faithfully followed all the steps in the blog, but cannot get the program to compile. I think the problem is in the way the header files are included, as indicated from the snippet of the output below. As far as I can tell, line 52 of /usr/include/c++/4.2.1/cstring is an include statement for <string.h> and the compiler includes Rccp/include/string.h instead of the string.h from std that is found earlier on the include path.
I am a novice in C++ so I'd really appreciate some pointers on how to proceed.
-Krishna
16:22:38 **** Incremental Build of configuration Debug for project MyTestRCppPackage ****
Info: Internal Builder is used for build
g++ -DINSIDE -I/Library/Frameworks/R.framework/Versions/2.15/Resources/include -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/RInside/include -O0 -g3 -Wall -c -fmessage-length=0 -arch x86_64 -v -o src/main.o ../src/main.cpp
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
/usr/llvm-gcc-4.2/bin/../libexec/gcc/i686-apple-darwin11/4.2.1/cc1plus -quiet -v -I/Library/Frameworks/R.framework/Versions/2.15/Resources/include -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/RInside/include -imultilib x86_64 -iprefix /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/ -dD -D__DYNAMIC__ -DINSIDE ../src/main.cpp -fPIC -quiet -dumpbase main.cpp -mmacosx-version-min=10.8.3 -m64 -mtune=core2 -auxbase-strip src/main.o -g3 -O0 -Wall -version -fmessage-length=0 -D__private_extern__=extern -o /var/folders/hc/vqp48jt56_v332kc3dqyf5780000gn/T//ccqdmOKI.s
ignoring nonexistent directory "/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/../../../../i686-apple-darwin11/include"
ignoring nonexistent directory "/usr/include/c++/4.2.1/i686-apple-darwin11/x86_64"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/../../../../i686-apple-darwin11/include"
#include "..." search starts here:
#include <...> search starts here:
/Library/Frameworks/R.framework/Versions/2.15/Resources/include
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/RInside/include
/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/include
/usr/include/c++/4.2.1
/usr/include/c++/4.2.1/backward
/usr/local/include
/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
GNU C++ version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) (i686-apple-darwin11)
compiled by GNU C version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00).
GGC heuristics: --param ggc-min-expand=150 --param ggc-min-heapsize=65536
Compiler executable checksum: b37fef824b01c0a99fb2679acf3b04f1
In file included from /usr/include/c++/4.2.1/cstring:52,
from /usr/include/c++/4.2.1/bits/stl_algobase.h:66,
from /usr/include/c++/4.2.1/memory:53,
from /usr/include/c++/4.2.1/tr1/hashtable:56,
from /usr/include/c++/4.2.1/tr1/unordered_map:37,
from /Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/platform/compiler.h:158,
from /Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/RcppCommon.h:26,
from /Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp.h:27,
from ../src/main.cpp:8:
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:52: error: 'internal' has not been declared
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:52: error: typedef name may not be a nested-name-specifier
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:52: error: expected ';' before '<' token
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:65: error: expected `)' before 'charsxp'
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:70: error: expected ',' or '...' before '&' token
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:75: error: expected unqualified-id before '&' token
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:75: error: expected ',' or '...' before '&' token
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:75: error: 'Rcpp::String::String()' cannot be overloaded
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:55: error: with 'Rcpp::String::String()'
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:85: error: 'Rcpp::String::String(int)' cannot be overloaded
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:70: error: with 'Rcpp::String::String(int)'
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:88: error: expected `)' before 'x'
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/string.h:89: error: expected `)' before 'x'
There are two entirely separate issues here:
Get all you need for Rcpp installed. OS X aspects should be documented on the relevant page maintained by Simon. If you have the tools, and have Rcpp install, then you should be able to do cppFunction('double nPi(int x) { return x*M_PI; }') which is uses functions supplied with Rcpp to create a callable C++ functions accessible to you as nPi() -- and nPi(2) should return a value.
Your choice of IDE and its settings. This is has little to do with 1. apart from requiring it to work to.
So I would work on 1. and see if I got that sorted out first, and only then turn to 2.
To summarize, the issue I faced was that include files in Rcpp with the sames names as those in std were in conflict. In particular, string.h from Rcpp was being included at a point where string.h from std was the right choice, and, as far as I could tell, this was due to the fact that paths specified via the -I directive are searched prior to the default paths.
I tried many different alternatives to solve this, including removing and re-installing XCode and the associated Command Line tools, as well as installing another g++ compiler using macports. None of these resolved the issue. I then used the -idirafter directive instead of the -I directive for the search path for include files for Rcpp and R. I got this hint from gcc include order broken?. This worked since these directories are now searched after the default paths. This precludes (at least so far!) the possibility that string.h from std and string.h from Rcpp come into conflict.
To get step 5 of http://blog.fellstat.com/?p=170 to work I had to set the -idirafter paths in PKG_CPPFLAGS in the file Makevars.
Thanks to everyone for your suggestions.
You simply have to remove include
/Library/Frameworks/R.framework/Resources/library/Rcpp/include/Rcpp
because it is:
unnecessary, as all R imports are in form <Rcpp/XXX>
causes this issue, as compiler looks for string.h in Rcpp directory (when it shouldn't).
I'm trying to compile c++ code with the following main definition:
int wmain(int argc, wchar_t** argv)
I can compile it correctly with Visual Studio, but g++ fails with the following error messages:
g++ -municode -o l1bCorrector AappL1bCorrector/l1bCorrector.o -L/usr/local/lib -Wl,-Bstatic -lboost_system-mt -lboost_filesystem-mt -lScanexUtilities -Wl,-Bdynamic
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../libcygwin.a(libcmain.o): In function `main':
/usr/src/debug/cygwin-1.7.17-1/winsup/cygwin/lib/libcmain.c:39: undefined reference to `_WinMain#16'
GCC has no support for wmain (even mingw GCC, which I expect to be the best in this respect).
If you need unicode command-line arguments as an array, you can use CommandLineToArgvW on the result of GetCommandLineW.
I am trying to compile a project but I'm getting an error right away that it's not seeing the header files that are in some packages inside the project. Here is a picture, notice that it is not finding the AwarenessMoment.h file, however it is in there.
Here is the output:
**** Build of configuration Debug for project RoyOS ****
make all
Building file: ../src/royos/vision/ImageRecognizer.cpp
Invoking: GCC C++ Compiler
g++ -I/home/igvc/Documents/teamigvc/trunk/RoyOS -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/royos/vision/ImageRecognizer.d" -MT"src/royos/vision/ImageRecognizer.d" -o"src/royos/vision/ImageRecognizer.o" "../src/royos/vision/ImageRecognizer.cpp"
In file included from ../src/royos/vision/ImageRecognizer.cpp:8:0:
../src/royos/vision/ImageRecognizer.h:11:29: fatal error: AwarenessMoment.h: No such file or directory
compilation terminated.
make: *** [src/royos/vision/ImageRecognizer.o] Error 1
Anyone know why it's not seeing these header files?
Thanks
There's definitely something wrong with the include path given to the compiler. The preprocessor can't find the header from the source file you are attempting to compile.
I think you could fix this by replacing
#include "AwarenessMoment.h"
with
#include "../sensor/AwarenessMoment.h"
Either that or alter the compiler include path to include the sensor directory and use:
#include <AwarenessMoment>
I installed wxWidgets and then followed the instructions to make it with MSYS. After it was done, I copied a sample from a site and put it on a project in eclipse. The code was:
#include <wx/string.h>
int main(int argc, char **argv)
{
wxPuts(wxT("A wxWidgets console application"));
}
But when I compile I get this error:
**** Build of configuration Debug for project test2 ****
**** Internal Builder is used for build ****
g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\test2.o ..\src\test2.cpp
..\src\test2.cpp:9:23: wx/string.h: No such file or directory
..\src\test2.cpp: In function `int main(int, char**)':
..\src\test2.cpp:13: error: `wxT' was not declared in this scope
..\src\test2.cpp:13: error: `wxPuts' was not declared in this scope
..\src\test2.cpp:13: warning: unused variable 'wxT'
..\src\test2.cpp:13: warning: unused variable 'wxPuts'
Build error occurred, build is stopped
Time consumed: 78 ms.
What did I do wrong?
I edited the settings but I still get this.
There is no -I still..
**** Build of configuration Debug for project Wx1 ****
**** Internal Builder is used for build ****
g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\simple.o ..\src\simple.cpp
In file included from ..\src\simple.cpp:1:
..\src\simple.h:1:19: wx/wx.h: No such file or directory
In file included from ..\src\simple.cpp:1:
..\src\simple.h:4: error: expected class-name before '{' token
..\src\simple.h:6: error: expected `,' or `...' before '&' token
..\src\simple.h:6: error: ISO C++ forbids declaration of `wxString' with no type
..\src\simple.cpp:3: error: expected `,' or `...' before '&' token
..\src\simple.cpp:4: error: ISO C++ forbids declaration of `wxString' with no type
..\src\simple.cpp: In constructor `Simple::Simple(int)':
..\src\simple.cpp:4: error: class `Simple' does not have any field named `wxFrame'
..\src\simple.cpp:4: error: `NULL' was not declared in this scope
..\src\simple.cpp:4: error: `wxID_ANY' was not declared in this scope
..\src\simple.cpp:4: error: `title' was not declared in this scope
..\src\simple.cpp:4: error: `wxDefaultPosition' was not declared in this scope
..\src\simple.cpp:4: error: `wxSize' was not declared in this scope
..\src\simple.cpp:6: error: `Centre' was not declared in this scope
..\src\simple.cpp:6: warning: unused variable 'Centre'
..\src\simple.cpp:4: warning: unused variable 'NULL'
..\src\simple.cpp:4: warning: unused variable 'wxID_ANY'
..\src\simple.cpp:4: warning: unused variable 'title'
..\src\simple.cpp:4: warning: unused variable 'wxDefaultPosition'
..\src\simple.cpp:4: warning: unused variable 'wxSize'
Build error occurred, build is stopped
Time consumed: 63 ms.
Here is a screenshot
screenshot http://imgkk.com/i/aRjvDe.jpg
What am I doing wrong?
Seems like you didn't set the correct include directories to find the wx headers (There is no -I... on the compiler command line).
You could add include directories in the project settings of a CDT project under C++->Settings->GNU C++->Include directories (or similar I don't have Eclipse running at the moment so the names way vary).
EDIT:
You have changed the "GCC Assembler" include paths. Since you don't program assembler this part isn't used. You need to edit the include paths in the "GCC C++ Compiler" path!
Perhaps the guide here might help you, as you have already built this library I guess you only read for the section titled Verification that wxWidgets Libraries Are Working onwards.