Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » Add a library C/C++ into project Titan
Add a library C/C++ into project Titan [message #1805813] Wed, 24 April 2019 14:34 Go to next message
Hung Duy Mai is currently offline Hung Duy MaiFriend
Messages: 8
Registered: April 2019
Junior Member
Hello experts,

Could you show me how to import/add libraries C/C++ and how to build a external library C/C++ with TITAN?

Thanks for your helping.

Regards
Duy
Re: Add a library C/C++ into project Titan [message #1805852 is a reply to message #1805813] Thu, 25 April 2019 12:43 Go to previous messageGo to next message
Lenard Nagy is currently offline Lenard NagyFriend
Messages: 54
Registered: September 2016
Member
Hi Duy,

Since I do not know if You are using Titan from CommandLine or from Eclipse IDE I'll explain both. Also, I'm supposing You are working under a Linux distribution.

Supposing You have a precompiled library "mylib.so" under the path "/usr/lib/"

For both methods You'll have to add the containing directory to the LD_LIBRARY_PATH variable.

Let's start with the Eclipse IDE part:
Right-Click on the name of the project in the left project browser pane and select "Properties"
In the "Properties for <PROJECTNAME>" window select "TITAN Project Property"
In the rigth pane around the middle click on "Internal makefile creation attributes" (here I'm supposing that You are using the default Eclipse-managed Makefile)
Under the menu item "Platform specific libraries" select "Linux". To add a library click on the "Add" icon (it is a leaf of paper with a green "+" sign)
In this window specify the name of the library, e.g. mylib (without the extension)
Under the menu item "Linker" select "Libraries". To add a library path in the "Library search path (-L)" list click on the "Add" icon (it is a leaf of paper with a green "+" sign)
In this window specify the path where the library is located (excluding the file name) either by manually typing it or selecting it from the path or environment variables or browsing for it in the file system using the "browse" button.

After this You should be able to compile and run the project.

CLI:

When building Your project from CLI You have do the modifications to the Makefile of the project:

- Add the containing directory path to the CPPFLAGS list with a "-I" prefix, e.g.:
CPPFLAGS = -D$(PLATFORM) -I. -I$(TTCN3_DIR)/include -I/usr/lib/

- Add Your library to the LINUX_LIBS, e.g:
LINUX_LIBS = -lxml2 -lpthread -lrt -lmylib

- Modify the $(EXECUTABLE): ... rule by adding the path containing the library with a "-L" prefix, e.g. the full rule should look like this:

$(EXECUTABLE): $(OBJECTS) $(BASE_OBJECTS)
	$(CXX) $(LDFLAGS) -o $@ $(OBJECTS) $(BASE_OBJECTS) \
	-L$(TTCN3_DIR)/lib -L$(OPENSSL_DIR)/lib -L$(XMLDIR)/lib -L/usr/lib/ \     <-- Look at the last -L item in this line
	-l$(TTCN3_LIB) -lcrypto \
	$($(PLATFORM)_LIBS) \
	|| if [ -f $(TTCN3_DIR)/bin/titanver ]; then $(TTCN3_DIR)/bin/titanver $(OBJECTS) $(BASE_OBJECTS); else : ; fi


After this You should be able to compile and run the project.

Regards,
Lenard Nagy
Re: Add a library C/C++ into project Titan [message #1805878 is a reply to message #1805852] Fri, 26 April 2019 10:53 Go to previous messageGo to next message
Jeno Attila Balasko is currently offline Jeno Attila BalaskoFriend
Messages: 80
Registered: September 2013
Location: Budapest, Hungary
Member

Hi Duy,

if you were interested in using C++ code from ttcn code, I would suggest you this as an interesting an useful source: https://github.com/eclipse/titan.Libraries.TCCUsefulFunctions

Best regards
Jeno
Re: Add a library C/C++ into project Titan [message #1805886 is a reply to message #1805813] Fri, 26 April 2019 14:42 Go to previous message
Hung Duy Mai is currently offline Hung Duy MaiFriend
Messages: 8
Registered: April 2019
Junior Member
Hi Lenard Nagy,

Thanks for your repose

Duy
Previous Topic:How to convert JSON into TTCN-3
Next Topic:Message segmentation in the legacy TCP test port
Goto Forum:
  


Current Time: Tue Apr 23 08:16:26 GMT 2024

Powered by FUDForum. Page generated in 0.03296 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top