Welcome, Guest
Username: Password: Remember me

TOPIC: Compilation and linking of C++ library to Telemac

Compilation and linking of C++ library to Telemac 5 years 11 months ago #32293

  • Fabien33
  • Fabien33's Avatar
Hi Telemac users et developers,

We are trying to integrate a new library made in C++ to Telemac.

This new library works fine with some Fortran Code.

The next step consists in linking the library at the moment when Telemac call one or another subroutine in the user fortran file...

Would it be possible to know how to add "objects files" in the processus of linking "Telemac2d.o" with another library ?

This linking processus is not well documented in "Telemac programming book" and it doesn't seem to be a simple makefile file.

Fabien
The administrator has disabled public write access.

Compilation and linking of C++ library to Telemac 5 years 11 months ago #32294

  • yugi
  • yugi's Avatar
  • OFFLINE
  • openTELEMAC Guru
  • Posts: 851
  • Thank you received: 244
Hi,

You can see examples of the usage of external library in systel.edf.cfg (in <root>/configs). Have a look at med.

In this file the "libs_all" defines what is passed at the linking.
It is used both for the compilation of the code and the compilation of the user subroutines.

Hope it helps.
There are 10 types of people in the world: those who understand binary, and those who don't.
The administrator has disabled public write access.
The following user(s) said Thank You: Fabien33

Compilation and linking of C++ library to Telemac 5 years 11 months ago #32357

  • Fabien33
  • Fabien33's Avatar
Hi Yugi,

Yes. It helped a lot as it works now very well.
Thank you for your anwer and advice.

Fabien
The administrator has disabled public write access.

Compilation and linking of C++ library to Telemac 5 years 10 months ago #32466

  • shenh
  • shenh's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 148
  • Thank you received: 37
Fabien and Yugi, I am performing essentially the same task - connecting telemac to an external C library. The library consists of ~50 C files. I have created a simple Fortran main program to interact with my C functions (i.e. compile C files to object files and then link them with fortran main to generate an exe file) and it worked very well.

Yugi, I was trying to follow your suggestion here - include my lib in libs_all. Should I archive all my object files into a single .lib file (I am using Windows 10 + v7p2r3), and then specify the .lib name after libs_all? I did try this option but it caused linkage error in linking to some libraries (e.g. splitsel.exe that is not related to what I am trying to interact between my lib and telemac).

Could you please provide more guidance to move forward? Thank you!

Hailiang
The administrator has disabled public write access.

Compilation and linking of C++ library to Telemac 5 years 10 months ago #32471

  • yugi
  • yugi's Avatar
  • OFFLINE
  • openTELEMAC Guru
  • Posts: 851
  • Thank you received: 244
Indeed creating one .lib file and adding it to libs_all is the way to go.

As for the error with splitsel it is because it was the first executable to compile with your library.

Could you show me you configuration file (systel.cfg) and how you generated you .lib file ?
And the error you have when compiling.
There are 10 types of people in the world: those who understand binary, and those who don't.
The administrator has disabled public write access.
The following user(s) said Thank You: shenh

Compilation and linking of C++ library to Telemac 5 years 10 months ago #32484

  • shenh
  • shenh's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 148
  • Thank you received: 37
Yugi, thanks for confirming compiling to a .lib file. I made a mistake in providing the correct .lib file path. I was using <root> without noticing it is C:\opentelemac-mascaret\v7p2r3 (with version folder included). My .lib file was saved at C:\opentelemac-mascaret\. After providing the correct path, the combined program works well. Regards,

Hailiang
The administrator has disabled public write access.
Moderators: pham

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.