Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29281 Discussions

IF 7.1 projects not creating .lib files

steveuk42
Beginner
1,877 Views
I am having a problem linking my program. I am using VC.NET 2003 and IF 7.1 with both C++ and Fortran projects. Each project is a Dynamic-link Library project. I have the settings for the Fortran linker to generate an *.lib file for my fortran projects.

For Fortran projects, a .dll and .pdb file is created, but no .lib file.

For C++ projects, a .dll, .pdb, .lib are all created.

I need this .lib file for each project to link my solution. Does anyone know why this would happen??

Thanks,
Steve
0 Kudos
9 Replies
Steven_L_Intel1
Employee
1,877 Views
Usually, it's because you haven't added an appropriate DLLEXPORT directive.

Steve
0 Kudos
steveuk42
Beginner
1,877 Views
I apologize I failed to mention that the .lib file is built fine when using Compaq Visual Fortran 6.6b to compile.
0 Kudos
Steven_L_Intel1
Employee
1,877 Views
Well, the answer is sort of the same. The compiler needs to recognize a DLLEXPORT directive. If you think the Intel compiler is not doing this properly, submit a support request (with sample) to Intel Premier Support.

Steve
0 Kudos
steveuk42
Beginner
1,877 Views
My project now produces a .lib file, but I get unresolved linker errors.

Heres the fortran code I have:

subroutine myfunc(param1)
!MS$ATTRIBUTES DLLEXPORT:: MYFUNC

! some if statements and other code

end

And in my C++ project that calls this function I have the following

extern "C"
{
void __declspec( dllimport ) __stdcall MYFUNC(float* param1);
};

double Cthick::Foo(double h, double w, int t, int s, int hd)
{
float _param1 = 1000.f;
MYFUNC(&_param1);

return param1/1000.f;
}

Here is the error I get when linking:
error LNK2019: unresolved external symbol __imp__MYFUNC@108 referenced in function "public: static double __cdecl Cthick::Foo(double,double,int,int,int)" (?Foo@Cthick@@SANNNHHH@Z)

I still do not understand why this works with CVF6.6B, but not IF7.1
0 Kudos
Steven_L_Intel1
Employee
1,877 Views
Does it really say MYFUNC@108? That makes no sense to me. I would expect __imp__MYFUNC@4. Why do you have braces after 'extern "C"'? I'm not really a C++ expert but I've never seen that before.

Note that for this to link, the C++ code needs to link to the export library created by the DLL build.

I suggest you wrap this up in a ZIP file and submit a report to Intel Premier Support. There's not enough here for me to know what is going wrong. Be sure to include all files that can reproduce the problem.

Steve
0 Kudos
steveuk42
Beginner
1,877 Views
Ok, I think I have an idea of whats going on.

Yes you were correct, it was MYFUNC@4
(My function really has 21 parameters hince 108, but i took it down to 1 just for simplicity here)

Anyways..

Back to the problem...

I compiled with Intel 7.1 integrated into .NET2003 and I did a dumpbin /exports file.lib and it shows:
______________________
Dump of file file.lib

File Type: LIBRARY

Exports

ordinal name

1 _MYFUNC
__________________________

Now.. when I compile with Compaq 6.6b and run a dumpbin I get:
Dump of file file.lib

File Type: LIBRARY

Exports

ordinal name

1 _MYFUNC@4
_________________________

This happens with other functions as well. It adds the underscore fine, but it's almost like Intel just is not putting the @4.

So thats the reason why when I run with Intel it cant find _MYFUNC@4, now how can I fix this?


(I tried using a def to export instead in both compag 6.6b and Intel 7.1 and the same thing happened)
0 Kudos
Steven_L_Intel1
Employee
1,877 Views
Intel Fortran and CVF use different default calling conventions. Intel Fortran uses the C convention, where one does not put a @n on the name, and CVF uses STDCALL, where one does. This in itself would not be responsible for not exporting the .lib file.

But I now see at least part of the problem. The C++ code uses __stdcall, which no longer matches the Fortran code if you build with Intel Fortran. Remove the __stdcall.

Steve
0 Kudos
steveuk42
Beginner
1,877 Views
I was unaware of that!

However my project does create a .lib file now, but the new problem is linking(see a couple posts up).
My C++ project cannot find _MYFUNC@4

So since Intel has a different calling convention, do you think my problem could be how I call the function in my C++ file?

Thanks for all your help!

Steve
0 Kudos
steveuk42
Beginner
1,877 Views
It compiles now!!!

The problem was the way I called the function on the C++ side...

I used int _CTHICKDLL __stdcall MYFUNC(params)

all I had to do was remove the __stdcall.

Again, thanks Steve for your help! This problem has been bugging me for a while!!

Now.. I hope the program will run...
0 Kudos
Reply