c++ - Creating a ".o" file from a Visual Studio 2012 project -


i wrote program class in visual studio 2012, , want run on linux machine. have tried compiling on linux machine, believe of libraries used not cross platform compatible. there anyway can create .o file run on linux, won't require me change code?

language: c++ here libraries used:

#include <iostream> #include <queue> #include <map> #include <climits>  #include <iterator> #include <algorithm> #include <fstream> #include <string> #include <iomanip> 

what happens when try compile in linux

main.cpp: in function ‘int main()’: main.cpp:110:24: error: no matching function call             'std::basic_ifstream<char>::basic_ifstream(std::string&)’ main.cpp:110:24: note: candidates are: /usr/include/c++/4.6/fstream:460:7: note: std::basic_ifstream<_chart,     _traits>::basic_ifstream(const char*, std::ios_base::openmode) [with _chart = char, _traits     = std::char_traits<char>, std::ios_base::openmode = std::_ios_openmode] /usr/include/c++/4.6/fstream:460:7: note:   no known conversion argument 1     ‘std::string {aka std::basic_string<char>}’ ‘const char*’ /usr/include/c++/4.6/fstream:446:7: note: std::basic_ifstream<_chart,     _traits>::basic_ifstream() [with _chart = char, _traits = std::char_traits<char>] /usr/include/c++/4.6/fstream:446:7: note:   candidate expects 0 arguments, 1 provided /usr/include/c++/4.6/fstream:420:11: note:     std::basic_ifstream<char>::basic_ifstream(const std::basic_ifstream<char>&) /usr/include/c++/4.6/fstream:420:11: note:   no known conversion argument 1     ‘std::string {aka std::basic_string<char>}’ ‘const std::basic_ifstream<char>&’ 

none of header files list appear specific visual studio or windows, assuming have installed correct c++ standard library on linux machine, should compile.

if want cross-compile, have download source code gcc, , c++ standard library headers , binaries onto windows machine. build compiler cross-compilation (which means installing "windows unix compatible version of gcc", such cygnus cygwin or gcc mingw). , it's not going straight forward achieve this. trust me, don't want unless have to.

a better solution, if don't want compile on linux machine reason, virtual machine installed on windows machine, , install linux on that, use linux vm compile system.

edit:

to clarify, based on edit in question: problem appears usage of c++11 features, presumably default in visual studio, gcc/g++ take more reserved approach. solution tell compiler use c++ 11 standard -std=c++11 on command line build. should allow extension of opening file name in string work correctly.


Comments