- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Link Copied
9 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Usually, it's because you haven't added an appropriate DLLEXPORT directive.
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I apologize I failed to mention that the .lib file is built fine when using Compaq Visual Fortran 6.6b to compile.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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...
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...
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page