PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

how to use pgi to build c++ code with dll file and lib file
Goto page 1, 2  Next
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Debugging and Profiling
View previous topic :: View next topic  
Author Message
longzhixi123



Joined: 10 Mar 2014
Posts: 4

PostPosted: Sun Mar 30, 2014 5:35 pm    Post subject: how to use pgi to build c++ code with dll file and lib file Reply with quote

hello ,new i can use gpi to built data.c code as data.dll、data.lib files。 but now i have a c++ code named main.cpp using data.dll and data.lib . how can i to build ? can you give me some advice.

and i use same code data.c

Code:
int __declspec(dllexport) data;
 void __declspec(dllexport)
func2(int i)
{
printf("func2: data == %d\n", data);
printf("func2: i == %d\n", i);
data = i;
}   


and use pgi to build data.dll and data.lib
also i use vs2010 to build another data1.dll and data1.lib
finally , i use vs2010 to build hello_world.cpp that used data.dll and data1.dll seperately. and when i use data1.dll and data1.lib , my program can run . but i got error when i use data.dll and data.lib as (External symbol __imp__data error LNK2001: could not be resolved
1>D:\goujl\hello_wolrd\Debug\hello_wolrd.exe: fatal error LNK1120: 2 unresolved external command).

and hello_world.cpp is
Code:

#include<iostream>
using namespace std;
//extern int add(int,int);
//extern int sub(int,int);

//#pragma comment(lib,"temp01.lib")
extern "C" int __declspec(dllimport) data;
extern "C" void __declspec(dllimport)func2(int);

int main(int argc, char*argv[])

{

//int result1 = add(2,5);

//int result2 = sub(6,3);

//cout<<result1<<"      "<<result2;
data=11;
func2(12);
return 0;

}
Back to top
View user's profile
cparrott



Joined: 02 May 2011
Posts: 146

PostPosted: Thu Apr 03, 2014 10:26 am    Post subject: Reply with quote

Hi,

Could you provide details on the command lines you are using to compile your example here? This would help us better understand the issue.

Thanks in advance.

Best regards,

+chris
Back to top
View user's profile
longzhixi123



Joined: 10 Mar 2014
Posts: 4

PostPosted: Thu Apr 03, 2014 7:39 pm    Post subject: can vs2010 use the dll and lib files build by PGI? Reply with quote

cparrott wrote:
Hi,

Could you provide details on the command lines you are using to compile your example here? This would help us better understand the issue.

Thanks in advance.

Best regards,

+chris


thanks for your message. my first situation like this : i hava a file named data.c and main.cpp . so i use PGI to build data.c to data.dll and data.lib :
Code:
$ pgcc -Bdynamic -c data.c
           $ pgcc -Mmakedll data.obj -o data.dll
 //now the d[b]ata.dll and data.lib[/b] have been found
          //and i use PGI to build main.cpp like this
           $ pgcpp -Bstatic main.cpp data.lib
////////////program run ok, ///////////



and sencond situation is i use microsoft vs2010 to build data.c ,and i got data1.dll and data1.lib. and use data1.dll and data1.lib to run main.cpp on microsoft vs2010 ,test ok .

and the third situation is : i copy data.dll and data.lib(build by PGI) to vs2010 project to build main.cpp , got erro :

(External symbol __imp__data error LNK2001: could not be resolved
1>D:\goujl\hello_wolrd\Debug\hello_wolrd.exe: fatal error LNK1120: 2 unresolved external command).

and my fouth situation is : i copy data1.dll and data1.lib to my PGI folder to build main.cpp using PGI,

Code:
$ pgcpp -Bstatic main.cpp data1.lib

and i got error like :
Code:
error LNK2019: unresolved external symbol __imp_data referenced in function main .


i confused, is the dll and lib build by PGI cannot be used by vs2010 ?

Thanks in advance.

Best regards

longzhixi123
Back to top
View user's profile
cparrott



Joined: 02 May 2011
Posts: 146

PostPosted: Fri Apr 04, 2014 8:15 am    Post subject: Reply with quote

Hi,

I checked with our C++ developer on this - objects created by PGI C++ are not interoperable with VS 2010 C++ at this time.

Best regards,

+chris
Back to top
View user's profile
longzhixi123



Joined: 10 Mar 2014
Posts: 4

PostPosted: Mon Apr 07, 2014 6:30 pm    Post subject: will you develop PGI to fix this problem? Reply with quote

cparrott wrote:
Hi,

I checked with our C++ developer on this - objects created by PGI C++ are not interoperable with VS 2010 C++ at this time.

Best regards,

+chris


hi , now i know the problem , will you have the plan to fix this problem . if hava, when ?

thanks a lot
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Debugging and Profiling All times are GMT - 7 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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