Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sumo-user] TraCI/C++ TraCIAPI

Hallo Sumo Users,

At first I want to say sorry for the long text. I hope you will read it anyway. I tried to describe my problem as accurate as possible so you might have a change to know what the problem could be or what mistake I am making. I want connect SUMO with a other program. Therefor I want to use the TraCI interface. At first I used TraCI/Interfacing_TraCI_from_Python. The documentation on the wiki is pretty good and I was able to connect to SUMO via TraCI and control one of the cars in the simulation. Now I want to do the same using TraCI/C++TraCIAPI. There for I tried to follow the guide I found in the wiki:
http://sumo.sourceforge.net/userdoc/TraCI/C%2B%2BTraCIAPI.html

I am trying for 3 days now just to get a TraCI connection using the example code given in the guide but I can't even compile the Project. I tried several things but nothing seems to work and I could really need some help on how to do it the right way. This is what I already tried:

1.     Creating and compiling a project in Visual Studio in Windows 7:
I already build SUMO in Visual Studio. Therefor I also added the Fox, XERCES, PROJ and GDAL libraries.

Then I created a new C++ Win32 Console Application and saved it in a file that is located on my desktop. In this project I created a new main.cpp file with the example code given in the guide. I copied all files out of the SUMO-source tree that where listed in the guide (TraCIAPI.h, TraCIAPI.cpp, socket.h, socket.cpp, storage.h, storage.cpp, TraCIConstants.h, TraCIDefs.h windows_config.h) and paste them into the folder where the main.cpp file was located. I add all files to the project and changed the paths for the include commands for all files in the same folder (e.g. #include <foreign/tcpip/socket.h> -> #include "socket.h" ) .
When I try to build it I get the following linking error: LNK2019 File:socket.obj

[cid:image001.png@01D3FCCC.46692460]


I couldn't find out how to solve this error since socket.obj is created by visual studio when I build the project.
I also tried to run it in x64. The same error accrued.
So my question here is: Is there anything I do wrong? Do all these files have to be located in the SUMO src folder so it can work? Do I have to use a special compiler? On the wiki I couldn't find anything about a compiler. However in the guide the project is compiled in the terminal using g++. So I thought maybe I will have to use MinGW as a compiler.



2.     Since this didn't work I also tried to build the project using the windows command line and downlaode the MinGW compiler. Therefor I used the command that was given in the guide:

g++ -std=c++0x -o test main.cpp TraCIAPI.cpp socket.cpp storage.cpp

When I do that I get the following error:

No such file or directory <netinet/in.h>



The netinet/in.h is included in the socket.spp file. I couldn't find any netinet folder in the SUMO source tree. Is that a Visual Studio add on or do I have to add another library? I read some where, that I have to include winsock2.h instead of <netinet/in.h>. So is the socket.spp file just not up to date?



3.     In the guide I also read about the TraCI testclient. However I couldn't find any description how to set it up or what the output would be when I run it. So I tried to build it with the windows console. There for I used the command that is also given in the guide when you want to build the TraCI file when, SUMO is already built and the files are not in the same directory, and patched it so it would run the testclient:

g++ -std=c++0x -o test tracitestclient.cpp ../utils/traci/libtraci.a ../foreign/tcpip/storage.o ../foreign/tcpip/socket.o -I .

that doesn't work because it can't find the libtraci.a, the storage.o and the socket.o files.
Is there any guide on how to set up the TraCi Testclient? Or can anyone tell me what my mistake is?


I would be really happy for any advice. I am not really sure what else I can try.
Thank you very much.

Best regards
Gunnar

PNG image

Attachment: Error.PNG
Description: Error.PNG

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/sumo-user

Back to the top