PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

-Mmakedll:export_all

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
Christopher Hulbert



Joined: 01 Dec 2005
Posts: 76

PostPosted: Thu Aug 28, 2008 11:49 am    Post subject: -Mmakedll:export_all Reply with quote

I sent this problem to the PGI technical support email, but never got a notification back.

When compiling a library that exports data, applications linking to the import library cannot see the symbols. Linking with an object file would allow the applications to see the symbol. Here is a small example

[chulbert@fourierwinx64 ~]$ cat file1.c
#include "file1.h"
char *str = "string";
[chulbert@fourierwinx64 ~]$ cat file1.h
extern char *str;
[chulbert@fourierwinx64 ~]$ cat file2.c
#include <stdlib.h>
#include <stdio.h>
#include "file1.h"

int main(void)
{
printf("%s\n",str);
}
[chulbert@fourierwinx64 ~]$ pgcc -Mmakedll:export_all file1.c
Creating library file1.lib and object file1.exp
[chulbert@fourierwinx64 ~]$ pgcc file2.c file1.lib
file2.obj : error LNK2019: unresolved external symbol _str referenced in function _main
file2.exe : fatal error LNK1120: 1 unresolved externals
file2.c:
Back to top
View user's profile
hongyon



Joined: 19 Jul 2004
Posts: 551

PostPosted: Thu Aug 28, 2008 1:55 pm    Post subject: Reply with quote

Hi,

-Mmakedll=export_all is not an external flag and we do not expose this flag to user because it could contain a bug(I believe it did have a bug before).

Your will need to specify in your code what you want to export or put it in *.def file. If you use .def file, the name must be the same as a source file name, for example file1.c must have file1.def.

From your code:

I would remove the include file1.h from file2.c if you are going to import it. Because you are having duplicate variable one that is included and the other is imported.

Here is some changes:

file1.c:
--------
#include "file1.h"
char __declspec(dllexport) *str = "string";

file1.h:
--------
extern char * str;

file2.c:
--------
#include <stdlib.h>
#include <stdio.h>

char __declspec(dllimport) *str;

int main(void) {
printf("%s\n",str);
}

Compile:
pgcc -Mmakedll file1.c -o libme.dll
pgcc -Mdll file2.c libme.lib


Hongyon
Back to top
View user's profile
Christopher Hulbert



Joined: 01 Dec 2005
Posts: 76

PostPosted: Fri Aug 29, 2008 4:22 am    Post subject: Reply with quote

I realize it's an "unsupported" flag, but it is a very convenient flag to have. Regardless, I think the issue could be fixed to improve the flag. The code I posted was a very simple example. Realistically, the code this occurs in is not mine so I would rather not maintain the source code. In the case of the Qhull library which is what I was compiling, I just added extra exports for the few symbols that this occurred with.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group