Yufeng-shen / TJ2GBE

Reconstruct grain boundary energy from triple junction geometries
BSD 3-Clause "New" or "Revised" License
1 stars 2 forks source link

Compilation issue #4

Closed sgbaird closed 3 years ago

sgbaird commented 3 years ago

I think at least C++14 is required, given that I got an error (using g++ (GCC) 5.5.0):

-bash-4.2$ g++ -o ../../bin/TJ2GBE.out main.cpp tj.cpp subdomain.cpp config.cpp -fopenmp
tj.cpp: In member function 'void TJ::write_bs()':
tj.cpp:5:48: error: no matching function for call to 'std::basic_ofstream<char>::basic_ofstream(std::__cxx11::basic_string<char>)'

By specifying the use of c++14 (I think you need to use at least g++ 5 to compile with the -std=c++14 flag):

-bash-4.2$ g++ -std=c++14 -o ../../bin/TJ2GBE.out main.cpp tj.cpp subdomain.cpp config.cpp -fopenmp

it seems to compile correctly, so it may be worth updating the README.

For the sake of completeness, here's the full error output / stack trace:

tj.cpp: In member function 'void TJ::write_bs()':
tj.cpp:5:48: error: no matching function for call to 'std::basic_ofstream<char>::basic_ofstream(std::__cxx11::basic_string<char>)'
     ofstream outputFile(cfg.outputDir+"GBs.txt");
                                                ^
In file included from config.hpp:7:0,
                 from tj.hpp:5,
                 from tj.cpp:1:
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:697:7: note: candidate: std::basic_ofstream<_CharT, _Traits>::basic_ofstream(const char*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::ios_base::openmode = std::_Ios_Openmode]
       basic_ofstream(const char* __s,
       ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:697:7: note:   no known conversion for argument 1 from 'std::__cxx11::basic_string<char>' to 'const char*'
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:682:7: note: candidate: std::basic_ofstream<_CharT, _Traits>::basic_ofstream() [with _CharT = char; _Traits = std::char_traits<char>]
       basic_ofstream(): __ostream_type(), _M_filebuf()
       ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:682:7: note:   candidate expects 0 arguments, 1 provided
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:656:11: note: candidate: std::basic_ofstream<char>::basic_ofstream(const std::basic_ofstream<char>&)
     class basic_ofstream : public basic_ostream<_CharT,_Traits>
           ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:656:11: note:   no known conversion for argument 1 from 'std::__cxx11::basic_string<char>' to 'const std::basic_ofstream<char>&'
tj.cpp: In member function 'void TJ::write_idxcell()':
tj.cpp:119:52: error: no matching function for call to 'std::basic_ofstream<char>::basic_ofstream(std::__cxx11::basic_string<char>)'
     ofstream outputFile(cfg.outputDir+"idxcell.txt");
                                                    ^
In file included from config.hpp:7:0,
                 from tj.hpp:5,
                 from tj.cpp:1:
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:697:7: note: candidate: std::basic_ofstream<_CharT, _Traits>::basic_ofstream(const char*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::ios_base::openmode = std::_Ios_Openmode]
       basic_ofstream(const char* __s,
       ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:697:7: note:   no known conversion for argument 1 from 'std::__cxx11::basic_string<char>' to 'const char*'
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:682:7: note: candidate: std::basic_ofstream<_CharT, _Traits>::basic_ofstream() [with _CharT = char; _Traits = std::char_traits<char>]
       basic_ofstream(): __ostream_type(), _M_filebuf()
       ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:682:7: note:   candidate expects 0 arguments, 1 provided
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:656:11: note: candidate: std::basic_ofstream<char>::basic_ofstream(const std::basic_ofstream<char>&)
     class basic_ofstream : public basic_ostream<_CharT,_Traits>
           ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:656:11: note:   no known conversion for argument 1 from 'std::__cxx11::basic_string<char>' to 'const std::basic_ofstream<char>&'
tj.cpp: In member function 'void TJ::write_neighborInfo()':
tj.cpp:159:48: error: no matching function for call to 'std::basic_ofstream<char>::basic_ofstream(std::__cxx11::basic_string<char>)'
     ofstream outputFile3(cfg.outputDir+"NN.txt");
                                                ^
In file included from config.hpp:7:0,
                 from tj.hpp:5,
                 from tj.cpp:1:
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:697:7: note: candidate: std::basic_ofstream<_CharT, _Traits>::basic_ofstream(const char*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::ios_base::openmode = std::_Ios_Openmode]
       basic_ofstream(const char* __s,
       ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:697:7: note:   no known conversion for argument 1 from 'std::__cxx11::basic_string<char>' to 'const char*'
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:682:7: note: candidate: std::basic_ofstream<_CharT, _Traits>::basic_ofstream() [with _CharT = char; _Traits = std::char_traits<char>]
       basic_ofstream(): __ostream_type(), _M_filebuf()
       ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:682:7: note:   candidate expects 0 arguments, 1 provided
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:656:11: note: candidate: std::basic_ofstream<char>::basic_ofstream(const std::basic_ofstream<char>&)
     class basic_ofstream : public basic_ostream<_CharT,_Traits>
           ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:656:11: note:   no known conversion for argument 1 from 'std::__cxx11::basic_string<char>' to 'const std::basic_ofstream<char>&'
tj.cpp: In member function 'void TJ::write_A()':
tj.cpp:183:66: error: no matching function for call to 'std::basic_ofstream<char>::basic_ofstream(std::__cxx11::basic_string<char>, const openmode&)'
     ofstream rowFile(cfg.outputDir+"rowA.binary",std::ios::binary);
                                                                  ^
In file included from config.hpp:7:0,
                 from tj.hpp:5,
                 from tj.cpp:1:
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:697:7: note: candidate: std::basic_ofstream<_CharT, _Traits>::basic_ofstream(const char*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::ios_base::openmode = std::_Ios_Openmode]
       basic_ofstream(const char* __s,
       ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:697:7: note:   no known conversion for argument 1 from 'std::__cxx11::basic_string<char>' to 'const char*'
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:682:7: note: candidate: std::basic_ofstream<_CharT, _Traits>::basic_ofstream() [with _CharT = char; _Traits = std::char_traits<char>]
       basic_ofstream(): __ostream_type(), _M_filebuf()
       ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:682:7: note:   candidate expects 0 arguments, 2 provided
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:656:11: note: candidate: std::basic_ofstream<char>::basic_ofstream(const std::basic_ofstream<char>&)
     class basic_ofstream : public basic_ostream<_CharT,_Traits>
           ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:656:11: note:   candidate expects 1 argument, 2 provided
tj.cpp:186:66: error: no matching function for call to 'std::basic_ofstream<char>::basic_ofstream(std::__cxx11::basic_string<char>, const openmode&)'
     ofstream colFile(cfg.outputDir+"colA.binary",std::ios::binary);
                                                                  ^
In file included from config.hpp:7:0,
                 from tj.hpp:5,
                 from tj.cpp:1:
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:697:7: note: candidate: std::basic_ofstream<_CharT, _Traits>::basic_ofstream(const char*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::ios_base::openmode = std::_Ios_Openmode]
       basic_ofstream(const char* __s,
       ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:697:7: note:   no known conversion for argument 1 from 'std::__cxx11::basic_string<char>' to 'const char*'
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:682:7: note: candidate: std::basic_ofstream<_CharT, _Traits>::basic_ofstream() [with _CharT = char; _Traits = std::char_traits<char>]
       basic_ofstream(): __ostream_type(), _M_filebuf()
       ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:682:7: note:   candidate expects 0 arguments, 2 provided
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:656:11: note: candidate: std::basic_ofstream<char>::basic_ofstream(const std::basic_ofstream<char>&)
     class basic_ofstream : public basic_ostream<_CharT,_Traits>
           ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:656:11: note:   candidate expects 1 argument, 2 provided
tj.cpp:189:66: error: no matching function for call to 'std::basic_ofstream<char>::basic_ofstream(std::__cxx11::basic_string<char>, const openmode&)'
     ofstream valFile(cfg.outputDir+"valA.binary",std::ios::binary);
                                                                  ^
In file included from config.hpp:7:0,
                 from tj.hpp:5,
                 from tj.cpp:1:
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:697:7: note: candidate: std::basic_ofstream<_CharT, _Traits>::basic_ofstream(const char*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::ios_base::openmode = std::_Ios_Openmode]
       basic_ofstream(const char* __s,
       ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:697:7: note:   no known conversion for argument 1 from 'std::__cxx11::basic_string<char>' to 'const char*'
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:682:7: note: candidate: std::basic_ofstream<_CharT, _Traits>::basic_ofstream() [with _CharT = char; _Traits = std::char_traits<char>]
       basic_ofstream(): __ostream_type(), _M_filebuf()
       ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:682:7: note:   candidate expects 0 arguments, 2 provided
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:656:11: note: candidate: std::basic_ofstream<char>::basic_ofstream(const std::basic_ofstream<char>&)
     class basic_ofstream : public basic_ostream<_CharT,_Traits>
           ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:656:11: note:   candidate expects 1 argument, 2 provided
tj.cpp: In constructor 'TJ::TJ(std::__cxx11::string)':
tj.cpp:392:15: error: 'exit' was not declared in this scope
         exit(1);
               ^
subdomain.cpp: In member function 'void Subdomain::write_cellInfo(std::__cxx11::string)':
subdomain.cpp:72:58: error: no matching function for call to 'std::basic_ofstream<char>::basic_ofstream(std::__cxx11::basic_string<char>, const openmode&)'
     ofstream numFile(outDir+"num.binary",std::ios::binary);
                                                          ^
In file included from subdomain.cpp:4:0:
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:697:7: note: candidate: std::basic_ofstream<_CharT, _Traits>::basic_ofstream(const char*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::ios_base::openmode = std::_Ios_Openmode]
       basic_ofstream(const char* __s,
       ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:697:7: note:   no known conversion for argument 1 from 'std::__cxx11::basic_string<char>' to 'const char*'
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:682:7: note: candidate: std::basic_ofstream<_CharT, _Traits>::basic_ofstream() [with _CharT = char; _Traits = std::char_traits<char>]
       basic_ofstream(): __ostream_type(), _M_filebuf()
       ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:682:7: note:   candidate expects 0 arguments, 2 provided
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:656:11: note: candidate: std::basic_ofstream<char>::basic_ofstream(const std::basic_ofstream<char>&)
     class basic_ofstream : public basic_ostream<_CharT,_Traits>
           ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:656:11: note:   candidate expects 1 argument, 2 provided
subdomain.cpp:75:58: error: no matching function for call to 'std::basic_ofstream<char>::basic_ofstream(std::__cxx11::basic_string<char>, const openmode&)'
     ofstream idsFile(outDir+"ids.binary",std::ios::binary);
                                                          ^
In file included from subdomain.cpp:4:0:
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:697:7: note: candidate: std::basic_ofstream<_CharT, _Traits>::basic_ofstream(const char*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::ios_base::openmode = std::_Ios_Openmode]
       basic_ofstream(const char* __s,
       ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:697:7: note:   no known conversion for argument 1 from 'std::__cxx11::basic_string<char>' to 'const char*'
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:682:7: note: candidate: std::basic_ofstream<_CharT, _Traits>::basic_ofstream() [with _CharT = char; _Traits = std::char_traits<char>]
       basic_ofstream(): __ostream_type(), _M_filebuf()
       ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:682:7: note:   candidate expects 0 arguments, 2 provided
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:656:11: note: candidate: std::basic_ofstream<char>::basic_ofstream(const std::basic_ofstream<char>&)
     class basic_ofstream : public basic_ostream<_CharT,_Traits>
           ^
/zapps7/gcc/5.5.0/include/c++/5.5.0/fstream:656:11: note:   candidate expects 1 argument, 2 provided
Yufeng-shen commented 3 years ago

Thank you! Actually, in my case std=c++11 is enough. The problem is constructing std::ofstream with std::string. Anyway, I updated the README.md. Thanks again!

sgbaird commented 3 years ago

Interesting, and good catch! I'm guessing I was originally compiling with less than c++11 then (whatever the default was on the server). Glad to help a bit.