Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: Unresolved external using clang


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 9 - Last Post: Sep 15, 2017 12:23 PM Last Post By: Vladimir Zhuchko Threads: [ Previous | Next ]
Nicolas Fortin

Posts: 4
Registered: 6/20/11
Unresolved external using clang  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 11, 2017 6:11 AM
Hello,

Since many years, our C++ VCL projects use lib file, generated from implib for some dll created in Visual Studio.

Now, just by switching from the classic compiler to the clang compiler, functions from Visual Studio get unresolved.

What should be done to fix this.

I can provide prototype projects for this.

Thanks in advance.
NF
Vladimir Zhuchko

Posts: 107
Registered: 1/22/98
Re: Unresolved external using clang  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 11, 2017 9:21 AM   in response to: Nicolas Fortin in response to: Nicolas Fortin
Nicolas Fortin wrote:
Hello,

Since many years, our C++ VCL projects use lib file, generated from implib for some dll created in Visual Studio.

Now, just by switching from the classic compiler to the clang compiler, functions from Visual Studio get unresolved.

What should be done to fix this.

I can provide prototype projects for this.

Thanks in advance.
NF
You have to use MKEXP.EXE instead of implib
--
With best regards
Dr. Vladimir Zhuchko
Nicolas Fortin

Posts: 4
Registered: 6/20/11
Re: Unresolved external using clang  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 11, 2017 10:23 AM   in response to: Vladimir Zhuchko in response to: Vladimir Zhuchko
Hello,

mkexp is for Win64, no ?

My goal is to build Win32, using clang compiler.

I just noticed something special. With the clang compiler, a prefix underscore is mentionned in the error message.

In the classic compiler mode, if I remove the .lib, I get unresolved external but, with the real function named (no prefix)

So, for a function declared as apxGetServices :

- classic compiler complains about unresolved apxGetServices

- clang compiler complains about unresolved _apxGetServices

For sure, the calling convention is not changing in the project options, when switch from classic to clang compiler.

Thanks in advance
NF

Vladimir Zhuchko wrote:
You have to use MKEXP.EXE instead of implib
--
With best regards
Dr. Vladimir Zhuchko

Edited by: Nicolas Fortin on Sep 11, 2017 10:27 AM
Vladimir Zhuchko

Posts: 107
Registered: 1/22/98
Re: Unresolved external using clang  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 12, 2017 12:06 AM   in response to: Nicolas Fortin in response to: Nicolas Fortin
Nicolas Fortin wrote:
Hello,

mkexp is for Win64, no ?

My goal is to build Win32, using clang compiler.

I just noticed something special. With the clang compiler, a prefix underscore is mentionned in the error message.

In the classic compiler mode, if I remove the .lib, I get unresolved external but, with the real function named (no prefix)

So, for a function declared as apxGetServices :

- classic compiler complains about unresolved apxGetServices

- clang compiler complains about unresolved _apxGetServices

For sure, the calling convention is not changing in the project options, when switch from classic to clang compiler.

Thanks in advance
NF

Vladimir Zhuchko wrote:
You have to use MKEXP.EXE instead of implib
--
With best regards
Dr. Vladimir Zhuchko

Edited by: Nicolas Fortin on Sep 11, 2017 10:27 AM

Yes, you are right, I checked my project with dll that I created using C# and it works fine for bcc32c.
Will check this topic:

https://forums.embarcadero.com/thread.jspa?threadID=153835&tstart=0

--
With best regards
Dr. Vladimir Zhuchko
Nicolas Fortin

Posts: 4
Registered: 6/20/11
Re: Unresolved external using clang  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 12, 2017 6:40 AM   in response to: Vladimir Zhuchko in response to: Vladimir Zhuchko
Vladimir Zhuchko wrote:

Yes, you are right, I checked my project with dll that I created using C# and it works fine for bcc32c.
Will check this topic:

https://forums.embarcadero.com/thread.jspa?threadID=153835&tstart=0

--
With best regards
Dr. Vladimir Zhuchko

Please see bug report for more information : https://quality.embarcadero.com/browse/RSP-19034

An example is also available.
Vladimir Zhuchko

Posts: 107
Registered: 1/22/98
Re: Unresolved external using clang  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 13, 2017 8:29 AM   in response to: Nicolas Fortin in response to: Nicolas Fortin
Nicolas Fortin wrote:
Vladimir Zhuchko wrote:

Yes, you are right, I checked my project with dll that I created using C# and it works fine for bcc32c.
Will check this topic:

https://forums.embarcadero.com/thread.jspa?threadID=153835&tstart=0

--
With best regards
Dr. Vladimir Zhuchko

Please see bug report for more information : https://quality.embarcadero.com/browse/RSP-19034

An example is also available.

You can check my bug report:
https://quality.embarcadero.com/browse/RSP-15569?filter=-2
--
With best regards
Dr. Vladimir Zhuchko
Vladimir Zhuchko

Posts: 107
Registered: 1/22/98
Re: Unresolved external using clang  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 14, 2017 4:49 AM   in response to: Nicolas Fortin in response to: Nicolas Fortin
Nicolas Fortin wrote:
Vladimir Zhuchko wrote:

Yes, you are right, I checked my project with dll that I created using C# and it works fine for bcc32c.
Will check this topic:

https://forums.embarcadero.com/thread.jspa?threadID=153835&tstart=0

--
With best regards
Dr. Vladimir Zhuchko

Please see bug report for more information : https://quality.embarcadero.com/browse/RSP-19034

An example is also available.

This is very strange, moreover, I tried to load your clib.dll by LoadLibrary, but could not.
I have my own dll created using VS C#, which contains function int add(int, int) and this function works fine for Win32 clang (lib was created by implib -a ...).

--
With best regards
Dr. Vladimir Zhuchko

Vladimir Zhuchko

Posts: 107
Registered: 1/22/98
Re: Unresolved external using clang  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 15, 2017 2:07 AM   in response to: Nicolas Fortin in response to: Nicolas Fortin
Nicolas Fortin wrote:
Vladimir Zhuchko wrote:

Yes, you are right, I checked my project with dll that I created using C# and it works fine for bcc32c.
Will check this topic:

https://forums.embarcadero.com/thread.jspa?threadID=153835&tstart=0

--
With best regards
Dr. Vladimir Zhuchko

Please see bug report for more information : https://quality.embarcadero.com/browse/RSP-19034

An example is also available.
I've checked your VS project.

To get result you have to set in the VS configuration C/C++ -> Advanced -> Calling Convention - __cdecl (/Gd).
After taht your test project will be linked.
--
With best regards
Dr. Vladimir Zhuchko
Nicolas Fortin

Posts: 4
Registered: 6/20/11
Re: Unresolved external using clang  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 15, 2017 12:03 PM   in response to: Vladimir Zhuchko in response to: Vladimir Zhuchko
Vladimir Zhuchko wrote:
I've checked your VS project.

To get result you have to set in the VS configuration C/C++ -> Advanced -> Calling Convention - __cdecl (/Gd).
After taht your test project will be linked.
--
With best regards
Dr. Vladimir Zhuchko

What explains the difference between using classic compiler vs clan compiler ?

Should behave the same behavior, isn't it ?
Vladimir Zhuchko

Posts: 107
Registered: 1/22/98
Re: Unresolved external using clang  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 15, 2017 12:23 PM   in response to: Nicolas Fortin in response to: Nicolas Fortin
Nicolas Fortin wrote:
Vladimir Zhuchko wrote:
I've checked your VS project.

To get result you have to set in the VS configuration C/C++ -> Advanced -> Calling Convention - __cdecl (/Gd).
After taht your test project will be linked.
--
With best regards
Dr. Vladimir Zhuchko

What explains the difference between using classic compiler vs clan compiler ?

Should behave the same behavior, isn't it ?

I don't know, I am using VS only sometimes and is not a guru, you can compare the clib.lib after implib
with/without these changes in the VS project and will see the difference.

--
With best regards
Dr. Vladimir Zhuchko
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02