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

How to compile the code? #3

Open
lbrianza opened this issue Oct 31, 2022 · 3 comments
Open

How to compile the code? #3

lbrianza opened this issue Oct 31, 2022 · 3 comments

Comments

@lbrianza
Copy link

Hello,

Sorry in advance because this is probably a naive question, but how to compile this package? I am very confused as I see no instructions at all, and no makefile.

I tried for example with g++, which returns several compilation errors, such as:
src/main.cpp: In function ‘int main(int, char**)’: src/main.cpp:34:11: error: no matching function for call to ‘ORB_SLAM2::System::System()’ 34 | System system; | ^~~~~~ In file included from include/Osmap.h:45, from src/main.cpp:15: include/System.h:62:5: note: candidate: ‘ORB_SLAM2::System::System(const string&, const string&, ORB_SLAM2::System::eSensor, bool)’ 62 | System(const string &strVocFile, const string &strSettingsFile, const eSensor sensor, const bool bUseViewer = true); | ^~~~~~ include/System.h:62:5: note: candidate expects 4 arguments, 0 provided src/main.cpp:36:36: error: no matching function for call to ‘ORB_SLAM2::KeyFrameDatabase::KeyFrameDatabase()’ 36 | system.mpKeyFrameDatabase = new KeyFrameDatabase; | ^~~~~~~~~~~~~~~~ In file included from include/KeyFrame.h:30, from include/Osmap.h:42, from src/main.cpp:15: include/KeyFrameDatabase.h:46:5: note: candidate: ‘ORB_SLAM2::KeyFrameDatabase::KeyFrameDatabase(const ORBVocabulary&)’ 46 | KeyFrameDatabase(const ORBVocabulary &voc); | ^~~~~~~~~~~~~~~~ include/KeyFrameDatabase.h:46:5: note: candidate expects 1 argument, 0 prov

(Please note that I already installed ORB_SLAM2, and it works fine)

Could you please provide some minimal instructions on how to compile this code? Thank you!

@AlejandroSilvestri
Copy link
Owner

Hi @lbrianza

First try not to use orb-slam2 with this project, by commenting out these includes (from KeyFrame.h to Tracking.h)

#include "KeyFrame.h"

You'll need to add libraries to the g++ command line, like OpenCV core and viz3d.

If you have problems, please copy the command line used to compile.

@lbrianza
Copy link
Author

lbrianza commented Nov 2, 2022

Hi @AlejandroSilvestri , thanks for your reply.

I am still a bit confused. If I comment those lines including headers from orb-slam2, I get dozens of errors - and that make sense to me because I see that the code uses some orbslam objects several times, like here:
[(https://github.com/AlejandroSilvestri/Osmap-viewer/blob/60e0f2bef3bb5e9f6fdbc9ef2ecb047fdb2c1ecc/include/Osmap.h#L220-L238)]

Am I missing something obvious? (most likely yes)

For reference, I am trying to compile with:
g++ -I /usr/local/include/opencv -I /usr/local/include/opencv2 -I include/ src/Osmap.cpp src/main.cpp -o osmap_viewer

Some of the errors that I get:
In file included from src/Osmap.cpp:28: include/Osmap.h:57:37: error: expected class-name before ‘{’ token 57 | class OsmapMapPoint: public MapPoint{ | ^ include/Osmap.h:60:21: error: expected ‘)’ before ‘*’ token 60 | OsmapMapPoint(Osmap*); | ~ ^ | ) include/Osmap.h:67:37: error: expected class-name before ‘{’ token 67 | class OsmapKeyFrame: public KeyFrame{ | ^ include/Osmap.h:70:21: error: expected ‘)’ before ‘*’ token 70 | OsmapKeyFrame(Osmap*); | ~ ^ | ) include/Osmap.h:78:27: error: expected class-name before ‘{’ token 78 | class OsmapMap: public Map{ | ^ In file included from src/Osmap.cpp:28: include/Osmap.h:221:3: error: ‘KeyFrameDatabase’ does not name a type 221 | KeyFrameDatabase &keyFrameDatabase; | ^~~~~~~~~~~~~~~~ include/Osmap.h:224:3: error: ‘System’ does not name a type; did you mean ‘system’? 224 | System &system; | ^~~~~~ | system include/Osmap.h:227:3: error: ‘Frame’ does not name a type 227 | Frame &currentFrame; | ^~~~~ include/Osmap.h:238:3: error: ‘KeyFrame’ does not name a type 238 | KeyFrame *pRefKF = NULL; | ^~~~~~~~ include/Osmap.h:273:15: error: expected ‘)’ before ‘&’ token 273 | Osmap(System &_system); | ~ ^~ | ) include/Osmap.h:435:3: error: ‘MapPoint’ does not name a type 435 | MapPoint *getMapPoint(unsigned int id); | ^~~~~~~~ src/Osmap.cpp:38:13: error: expected constructor, destructor, or type conversion before ‘(’ token 38 | Osmap::Osmap(System &_system): | ^

@AlejandroSilvestri
Copy link
Owner

@lbrianza

So sorry, I haven't used this code in a long time.

I'm trying you to test it with dummy map. You need to set OSMAP_DUMMY_MAP, that will include Dummymap.h and ignore those include you already commented out.

You also need to add the libraries with -l in your g++ command line. There are four you can see here:

<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.link.option.libs.1101587342" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" useByScannerDiscovery="false" valueType="libs">

Look for them in
/usr/local/lib/opencv4 and /usr/local/lib

I see this project uses protocol buffers version 3006001. Won't work with another version. If you use a different version, you should regenerate headers. proto file is in osmap repository, and this can be cumbersome unless you are familiar with it.

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

2 participants