Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

f90 + c++ + opengl

imeca
Beginner
585 Views
Goodevening friends,

i used to build a program with intel fortran. this program uses some fortran files, some c and c++ files.
using cl i compiled the c and c++ programs and transformed them to object files.
using ifort i compiled the fortran programs and transformed them to object files.

using ifort again, i linkedall theobjects into the executable file.
this happened succesfully.

Now i wanted to extend my executable and add some graphical tools using the openGL libraries. I programmed some functions in c++ files which worked fine with other compilers like compiling in the interface of visual studio. but when i tried to compile the same way i used to do, the intel visual fortran compiler gives an error saying that there are unresolved external symbols referred in your program. i guess that the libraries of OPENGL must be added somehow to the link command using ifort. if that is the case, i will be grateful if some one help me to figure out this way. if not, can you show me the way to compile fortran programs andc++ using opengl programs with intel visual fortan like i explained above?

thank you in advance.
0 Kudos
4 Replies
mecej4
Honored Contributor III
585 Views
For the linker to be able to link (i) your C objects, (ii) your Fortran objects and (iii) the OpenGL libraries, you have to induce the C and Fortran compilers to use a name mangling scheme that is compatible with the names that exist in the OpenGL libraries. Alternatively, to a smoothly functioning project with a set of C objects and libraries you can add Fortran sources using the Fortran 2003 C-interoperability modules.

See this recent thread.
0 Kudos
imeca
Beginner
585 Views
thank you for your answer, but excuse my ignorance, i didn't understand very well what you proposed for me to do. would you please show me the way through a little example using all these components?

All I want, is what to write additionally in the source code and in the compiler instructions for compiling the objects and building the executable.

Thank you in advance.
0 Kudos
Steven_L_Intel1
Employee
585 Views
Intel Visual Fortran provides the module IFOPNGL which declares OpenGL routines, types and constants. Add:

USE IFOPNGL

to get access to these. Note that the names of functions are preceded with "f" and types may have _T added to their names. You should take a look at the provided OpenGL sample programs to get a feel for how it works, and it also helps to read the source for ifopngl.f90 in the compiler's Include directory. Using the module will automatically link in the correct libraries.
0 Kudos
imeca
Beginner
585 Views
Thank you Steve for your answer, I think i've already tried it but i didn't succeed. So i tried another way. I will try it again and see what will be the result. I ll come back to you when finished.

Thank you again.
0 Kudos
Reply