Closed yusufcananar closed 7 months ago
I have managed to build successfully. Makefile.common :
# This is required for 3rd party nlohmann/json header
TRICK_SWIG_EXCLUDE += /$(TRICK_HOME)/third_party
TRICK_ICG_EXCLUDE += $(TRICK_HOME)/third_party
# This is required for 3rd party MongoDB library
TRICK_EXEC_LINK_LIBS += -L/usr/local/lib -lpthread -lcrypto -lssl -lmongocxx -lbsoncxx
Also adding preprocessor directives to my adapter(DRMongo) where i used json functions :
#ifndef SWIG
#include "nlohmann/json.hpp"
#endif
.
.
.
#ifndef SWIG
/**
* @brief Turns variable strings into json format
* @return json
*/
nlohmann::json variable_string_to_json(nlohmann::json j, std::string str, std::string value);
#endif
But I know it is not the best practice(or it is just the beginning of it) for adding a 3rd party. I have seen civetweb and hdf5 usage but they have many relations (and conditions) in the code like in ./configure or Makefile.common or even makefiles of their own folder has sth unique.
What is the harm excluding from swig and ICG? I have tried my code is working as expected nothing broken. I am afraid if excluding the class from swig harms me in later.
Could also use TRICK_EXCLUDE to instruct both SWIG and ICG to skip. Won't be able to data recording and input process
Just to follow up with what @hchen99 said, if you SWIG_EXCLUDE then you lose the ability to interact with your classes via the input processor or variable server (same thing really). If you ICG_EXCLUDE, then Trick will not be able to manage the memory, provide data recording, drop or load checkpoints, and things like that. If you have any further questions please reach out.
I am using a library called
nlohmann/json.hpp
(which is a single header file project) withintrick_source/sim_services/DRMongo.cpp
(I am adding db adapter to trick). I have created a folder called third_party and loaded the library inside asthird_party/include/nlohmann/json.hpp
atTRICK_HOME
When imake
the trick I got this following error and my build is not completed. I think swig or icg (where i am not familiar its working principle) is the reason for this error. I want to know how to add third party libraries to trick build system?I have tried to add
TRICK_SWIG_EXCLUDE += ${TRICK_HOME}/third_party/include
this toMakefile.common
but still same error. Also I have added the lines below to Makefile at TRICK_HOME dir;Make system is a little bit complicated for me especially in this project sorry in advance if i am asking very simple task. Also is there any document that describes trick build system(not for the sims but for the source code development)?