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.
Related
I'm trying to invoke Parsido function in mex file using gfortran compiler on Linux system. I use following instruction to compile:
mex '-I ${EBROOTIMKL}/mkl/include'...,
'-L ${EBROOTIMKL}/mkl/lib'...,
-lmkl_rt...,
pardiso_sym_f90.f90 ero_dep_fortran.F -output ero_dep_fortran
I can successfully compile the mex file, but when I excute, Matlab crashes without any error information. I know it might be due to the use of -lmkl_rt, which might conflict with the Intel iomp5 implementation of OpenMP which MATLAB uses.
Any suggestions will be appreciated.
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.
I installed GCC (4.8.1) this morning and Eclipse Kepler (SR2). My Hello World compiled and ran fine, so I'm moving toward my goal of writing a C++ app using Boost. I installed Boost to "C:\Program Files\boost\boost_1_55_0" and added this path to Project>Properties>C/C++ General>Paths and Symols>[tab]Includes>GNU C++. However, when I compile, the path isn't showing up in the g++ command line, so understandably, the header file isn't getting found.
15:55:24 **** Incremental Build of configuration Debug for project BoostApp ****
Info: Internal Builder is used for build
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\BoostApp.o" "..\\src\\BoostApp.cpp"
..\src\BoostApp.cpp:1:32: fatal error: boost/filesystem.hpp: No such file or directory
#include "boost/filesystem.hpp"
^
compilation terminated.
15:55:24 Build Finished (took 78ms)
I realize this is a newb question and spent a few hours searching around and finding mostly direction to set the path, which I've done. I've checked the install and the header file is there. I've also done my own command line compile adding "-I C:\Program Files\boost\boost_1_55_0" to the command line and GCC found the header file fine.
Not sure where I'm going wrong. As mentioned, it's a new install of GCC, Eclipse, and Boost, so maybe I went wrong somewhere during the install or maybe creating the project? Or just a newb question? Below is the app I'm compiling which I copied from rosettacode.com
#include "boost/filesystem.hpp"
#include "boost/regex.hpp"
#include <iostream>
using namespace boost::filesystem;
int main()
{
path current_dir("."); //
boost::regex pattern("a.*"); // list all files starting with a
for (recursive_directory_iterator iter(current_dir), end;
iter != end;
++iter)
{
std::string name = iter->path().filename().string();
if (regex_match(name, pattern))
std::cout << iter->path() << "\n";
}
}
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).