Search code examples
c++mysqlomnet++

Omnet + MySQL not working


Newbie on Omnetpp here and already running into a few problems. I'm using Omnet to create a wireless sensor network who's gonna collect data and store on MySQL for later use. The network is very simple: 2 types of sensors, one collects data and the other stores it. As for the sensors they function very well except for the connect and store data part.

To store data I have a MySQL server running and one table set. It happens that when I compile the simulation I got some errors:

08:57:20 **** Build of configuration gcc-debug for project DB ****
make MODE=debug CONFIGNAME=gcc-debug all 
dbSyncSensor.cc
Makefile:93: recipe for target 'out/gcc-debug//dbSyncSensor.o' failed
In file included from dbSyncSensor.cc:11:0:
C:\Program Files (x86)\MySQL\MySQL Connector C++ 1.1.6\include\mysql_connection.h:30:32: fatal error: cppconn/connection.h: No such file or directory
 #include <cppconn/connection.h>
                                ^
compilation terminated.
make: *** [out/gcc-debug//dbSyncSensor.o] Error 1

08:57:21 Build Finished (took 1s.629ms)

The source code of the simulation is attached. I have installer Omnetpp on Windows + MySQL Connector C 6.1 and MySQL Connector C++ 1.1.6.

Am I missing something? How can I make MySQL works with omnet?

If you need to see the code of the simulation let me know.


Solution

  • You have to add path to header files of MySQL Connector C++ in your OMNeT++ project.

    In order to do this go to:

    • Project | Properties | C/C++ General | Paths and Symbols, choose Includes tab,
    • mark GNU C++ then click Add | File system... and select C:\Program Files (x86)\MySQL\MySQL Connector C++ 1.1.6\include\ directory.


    Moreover, to avoid linker errors add paths to MySQL libraries. In Paths and Symbols choose Library Paths tab then add C:\Program Files (x86)\MySQL\MySQL Connector C++ 1.1.6\lib\ directory. Then from main menu go to Project | Properties | OMNeT++ | Makemake | select your source directory, then choose Options... on the right side, go to Link, More>> | Add icon and write mysqlcppconn (without extension).