Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error during make #4

Open
bigdoods opened this issue Jan 22, 2019 · 7 comments
Open

Error during make #4

bigdoods opened this issue Jan 22, 2019 · 7 comments

Comments

@bigdoods
Copy link

bigdoods commented Jan 22, 2019

Hi,

The project looks really cool so I tried to build it. I have not touched C/C++ before so excuse me but I have an error during the make process that I can't understand.

I am on ubuntu 18.04. Cmake version 3.10.2. OpenCV version 3.4.2. I installed the following packages through the ubuntu to package manager for OpenMPI dependency:

  • openmpi-bin
  • openmpi-common
  • openssh-client
  • openssh-server

The steps I take are as follows:

  1. Install dependencies
  2. Download sample file birdfountain_station1_xyz_intensity_rgb.7z and unziphere
  3. Update main.cpp line 117 to reflect absolute location of downloaded sample
  4. Update main.cpp line 118 to update the results destination
  5. run cmake at folder root
  6. run make at folder root

This produces the following error:

[ 25%] Building CXX object src/CMakeFiles/LineFromPointCloud.dir/main.cpp.o
/home/bigdoods/projects/3DLineDetection/src/main.cpp:115:11: error: ‘::main’ must return ‘int’
 void main() 
           ^
src/CMakeFiles/LineFromPointCloud.dir/build.make:110: recipe for target 'src/CMakeFiles/LineFromPointCloud.dir/main.cpp.o' failed
make[2]: *** [src/CMakeFiles/LineFromPointCloud.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:85: recipe for target 'src/CMakeFiles/LineFromPointCloud.dir/all' failed
make[1]: *** [src/CMakeFiles/LineFromPointCloud.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Could you please advise how to get working please?

@mharv
Copy link

mharv commented Jan 27, 2019

Hey @bigdoods,

Mate, in the main.cpp file, try changing "void main()" to "int main()" on line 115,
then add "return 0;" on the last line of the main block under the writeOutLines() line 134.

This solved the problem for me. Good luck!

@bigdoods
Copy link
Author

Hey. Thanks for the reply and it builds now - Thanks!

However, I am confused by the output as there does not seem to be any at the write path that I have updated at string fileOut. What is the expected output?

My new main for reference:

int main()
{ 
        string fileData = "/home/bigdoods/Downloads/birdfountain_station1_xyz_intensity_rgb (1).txt";
        string fileOut = "/home/bigdoods/Downloads/lines";

        // read in data
        PointCloud<double> pointData;
        readDataFromFile( fileData, pointData );

        int k = 20;
        LineDetection3D detector;
        std::vector<PLANE> planes;
        std::vector<std::vector<cv::Point3d> > lines;
        std::vector<double> ts;
        detector.run( pointData, k, planes, lines, ts );
        cout<<"lines number: "<<lines.size()<<endl;
        cout<<"planes number: "<<planes.size()<<endl;

        writeOutPlanes( fileOut, planes, detector.scale );
        writeOutLines( fileOut, lines, detector.scale );
        return 0;
}

Thanks

@cuge1995
Copy link

hey, this is the bugs, I've followed your guys solution, but still cannot run successful.

Scanning dependencies of target LineFromPointCloud
[ 12%] Building CXX object src/CMakeFiles/LineFromPointCloud.dir/main.cpp.o
[ 25%] Linking CXX executable LineFromPointCloud
CMakeFiles/LineFromPointCloud.dir/main.cpp.o: In function `main':
main.cpp:(.text+0xd18): multiple definition of `main'
CMakeFiles/LineFromPointCloud.dir/build/CMakeFiles/3.10.2/CompilerIdCXX/CMakeCXXCompilerId.cpp.o:CMakeCXXCompilerId.cpp:(.text+0x0): first defined here
CMakeFiles/LineFromPointCloud.dir/build/CMakeFiles/3.10.2/CompilerIdC/CMakeCCompilerId.c.o:(.data.rel.local+0x0): multiple definition of `info_compiler'
CMakeFiles/LineFromPointCloud.dir/build/CMakeFiles/3.10.2/CompilerIdCXX/CMakeCXXCompilerId.cpp.o:(.data.rel.local+0x0): first defined here
CMakeFiles/LineFromPointCloud.dir/build/CMakeFiles/3.10.2/CompilerIdC/CMakeCCompilerId.c.o:(.data.rel.local+0x8): multiple definition of `info_platform'
CMakeFiles/LineFromPointCloud.dir/build/CMakeFiles/3.10.2/CompilerIdCXX/CMakeCXXCompilerId.cpp.o:(.data.rel.local+0x8): first defined here
CMakeFiles/LineFromPointCloud.dir/build/CMakeFiles/3.10.2/CompilerIdC/CMakeCCompilerId.c.o:(.data.rel.local+0x10): multiple definition of `info_arch'
CMakeFiles/LineFromPointCloud.dir/build/CMakeFiles/3.10.2/CompilerIdCXX/CMakeCXXCompilerId.cpp.o:(.data.rel.local+0x10): first defined here
CMakeFiles/LineFromPointCloud.dir/build/CMakeFiles/3.10.2/CompilerIdC/CMakeCCompilerId.c.o:(.data.rel.local+0x18): multiple definition of `info_language_dialect_default'
CMakeFiles/LineFromPointCloud.dir/build/CMakeFiles/3.10.2/CompilerIdCXX/CMakeCXXCompilerId.cpp.o:(.data.rel.local+0x18): first defined here
CMakeFiles/LineFromPointCloud.dir/build/CMakeFiles/3.10.2/CompilerIdC/CMakeCCompilerId.c.o: In function `main':
CMakeCCompilerId.c:(.text+0x0): multiple definition of `main'
CMakeFiles/LineFromPointCloud.dir/build/CMakeFiles/3.10.2/CompilerIdCXX/CMakeCXXCompilerId.cpp.o:CMakeCXXCompilerId.cpp:(.text+0x0): first defined here
CMakeFiles/LineFromPointCloud.dir/build/CMakeFiles/feature_tests.c.o: In function `main':
feature_tests.c:(.text+0x0): multiple definition of `main'
CMakeFiles/LineFromPointCloud.dir/build/CMakeFiles/3.10.2/CompilerIdCXX/CMakeCXXCompilerId.cpp.o:CMakeCXXCompilerId.cpp:(.text+0x0): first defined here
CMakeFiles/LineFromPointCloud.dir/build/CMakeFiles/feature_tests.cxx.o: In function `main':
feature_tests.cxx:(.text+0x0): multiple definition of `main'
CMakeFiles/LineFromPointCloud.dir/build/CMakeFiles/3.10.2/CompilerIdCXX/CMakeCXXCompilerId.cpp.o:CMakeCXXCompilerId.cpp:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
src/CMakeFiles/LineFromPointCloud.dir/build.make:265: recipe for target 'src/LineFromPointCloud' failed
make[2]: *** [src/LineFromPointCloud] Error 1
CMakeFiles/Makefile2:85: recipe for target 'src/CMakeFiles/LineFromPointCloud.dir/all' failed
make[1]: *** [src/CMakeFiles/LineFromPointCloud.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

@cuge1995
Copy link

test on another machine, the bug is different.

Scanning dependencies of target LineFromPointCloud
[ 20%] Building CXX object src/CMakeFiles/LineFromPointCloud.dir/main.cpp.o
/home/amax/ngrok/opencv/3DLineDetection/src/main.cpp: In function ‘void readDataFromFile(std::__cxx11::string, PointCloud<double>&)’:
/home/amax/ngrok/opencv/3DLineDetection/src/main.cpp:19:35: error: no matching function for call to ‘std::basic_ifstream<char>::basic_ifstream(std::__cxx11::string&)’
  std::ifstream ptReader( filepath );
                                   ^
In file included from /home/amax/ngrok/opencv/3DLineDetection/src/main.cpp:2:0:
/usr/include/c++/5/fstream:495:7: note: candidate: 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]
       basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in)
       ^
/usr/include/c++/5/fstream:495:7: note:   no known conversion for argument 1 from ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ to ‘const char*’
/usr/include/c++/5/fstream:481:7: note: candidate: std::basic_ifstream<_CharT, _Traits>::basic_ifstream() [with _CharT = char; _Traits = std::char_traits<char>]
       basic_ifstream() : __istream_type(), _M_filebuf()
       ^
/usr/include/c++/5/fstream:481:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/5/fstream:455:11: note: candidate: std::basic_ifstream<char>::basic_ifstream(const std::basic_ifstream<char>&)
     class basic_ifstream : public basic_istream<_CharT, _Traits>
           ^
/usr/include/c++/5/fstream:455:11: note:   no known conversion for argument 1 from ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ to ‘const std::basic_ifstream<char>&’
src/CMakeFiles/LineFromPointCloud.dir/build.make:62: recipe for target 'src/CMakeFiles/LineFromPointCloud.dir/main.cpp.o' failed
make[2]: *** [src/CMakeFiles/LineFromPointCloud.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:85: recipe for target 'src/CMakeFiles/LineFromPointCloud.dir/all' failed
make[1]: *** [src/CMakeFiles/LineFromPointCloud.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

@cuge1995
Copy link

cuge1995 commented Aug 11, 2020

this was solved by update gcc to 7, but still have bugs.

[ 20%] Linking CXX executable LineFromPointCloud
CMakeFiles/LineFromPointCloud.dir/test.cpp.o: In function `readDataFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, PointCloud<double>&)':
test.cpp:(.text+0x0): multiple definition of `readDataFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, PointCloud<double>&)'
CMakeFiles/LineFromPointCloud.dir/main.cpp.o:main.cpp:(.text+0x0): first defined here
CMakeFiles/LineFromPointCloud.dir/test.cpp.o: In function `writeOutPlanes(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<PLANE, std::allocator<PLANE> >&, double)':
test.cpp:(.text+0x27a): multiple definition of `writeOutPlanes(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<PLANE, std::allocator<PLANE> >&, double)'
CMakeFiles/LineFromPointCloud.dir/main.cpp.o:main.cpp:(.text+0x27a): first defined here
CMakeFiles/LineFromPointCloud.dir/test.cpp.o: In function `writeOutLines(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<std::vector<cv::Point3_<double>, std::allocator<cv::Point3_<double> > >, std::allocator<std::vector<cv::Point3_<double>, std::allocator<cv::Point3_<double> > > > >&, double)':
test.cpp:(.text+0x88e): multiple definition of `writeOutLines(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<std::vector<cv::Point3_<double>, std::allocator<cv::Point3_<double> > >, std::allocator<std::vector<cv::Point3_<double>, std::allocator<cv::Point3_<double> > > > >&, double)'
CMakeFiles/LineFromPointCloud.dir/main.cpp.o:main.cpp:(.text+0x88e): first defined here
CMakeFiles/LineFromPointCloud.dir/test.cpp.o: In function `main':
test.cpp:(.text+0xcf6): multiple definition of `main'
CMakeFiles/LineFromPointCloud.dir/main.cpp.o:main.cpp:(.text+0xcf6): first defined here
collect2: error: ld returned 1 exit status
src/CMakeFiles/LineFromPointCloud.dir/build.make:189: recipe for target 'src/LineFromPointCloud' failed
make[2]: *** [src/LineFromPointCloud] Error 1
CMakeFiles/Makefile2:85: recipe for target 'src/CMakeFiles/LineFromPointCloud.dir/all' failed
make[1]: *** [src/CMakeFiles/LineFromPointCloud.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

@cuge1995
Copy link

I find this may solved in here, but I cannot solve it, anyone can help me out ?

@Abbsalehi
Copy link

I've already run the code, and got the lines.txt and planes.txt, could you please let me know how to visualize them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@bigdoods @mharv @cuge1995 @Abbsalehi and others