public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
* RE: Problem linking in pthread librarry.... (Newbie)
@ 2004-01-08 13:50 Kok YihTzye-CYK011
  0 siblings, 0 replies; 4+ messages in thread
From: Kok YihTzye-CYK011 @ 2004-01-08 13:50 UTC (permalink / raw)
  To: 'Srdjan', pthreads-win32

I am facing the same problem as well. I am very interested to know the answer.



-----Original Message-----
From: pthreads-win32-owner@sources.redhat.com [mailto:pthreads-win32-owner@sources.redhat.com] On Behalf Of Srdjan
Sent: Thursday, January 08, 2004 8:31 PM
To: pthreads-win32@sources.redhat.com
Subject: Problem linking in pthread librarry.... (Newbie)


Hi,

After reading all the readme's and FAQs I still have a bit of a problem linking with pthread for win32. Somebody might have already solved it...

Here is the problem....

I am porting a small daemon program from linux to win32 (... yes, I know...). Anyway, becasue this little beast is supposed to be used on systems that I am unable to install the pthread.dll, I am trying to build a static pthread library and link it in with my code.

I have fudged building process using VC7.1 (.NET) so it does build a .lib file, however, when I try linking with my code, I get the following link
problems:

============================================================================
=============
fdca.obj : error LNK2019: unresolved external symbol __imp__pthread_join referenced in function _main fdca.obj : error LNK2019: unresolved external symbol __imp__pthread_create referenced in function _main fdca_schedule.obj : error LNK2001: unresolved external symbol __imp__pthread_create fdca_collect.obj : error LNK2019: unresolved external symbol __imp__pthread_exit referenced in function _fdca_collect fdca_command.obj : error LNK2019: unresolved external symbol __imp__pthread_exit referenced in function _fdca_command fdca_schedule.obj : error LNK2001: unresolved external symbol __imp__pthread_exit
ds.lib(ds.obj) : error LNK2019: unresolved external symbol __imp__pthread_mutex_init referenced in function _ds_list_init
ds.lib(ds.obj) : error LNK2019: unresolved external symbol __imp__pthread_mutex_unlock referenced in function _ds_list_insert
ds.lib(ds.obj) : error LNK2019: unresolved external symbol __imp__pthread_mutex_lock referenced in function _ds_list_insert .\/winagent.exe : fatal error LNK1120: 7 unresolved externals ============================================================================
=============

Now, I am sure I have stuffed up something, but I can't figure out what (obvious conclusion :-). My code seems to generate '__imp__function_name' instead of '_function_name'. I have a number of other external static libraries I am linking with, but they all seem to be linking in happily.

The Makefile with nmake builds only a DLL version, and I am trying at the moment to get it to build a static lib too, but with not much success.

I would be ethernally grateful if somebody was able to quickly identify what I am doing wrong.

Cheers,

Srdjan
Melbourne

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problem linking in pthread librarry.... (Newbie)
  2004-01-08 14:34 ` Ed Hume
@ 2004-01-13  6:11   ` Ross Johnson
  0 siblings, 0 replies; 4+ messages in thread
From: Ross Johnson @ 2004-01-13  6:11 UTC (permalink / raw)
  To: Ed Hume; +Cc: Srdjan, pthreads-win32

Ed Hume wrote:

> I believe the __imp__ prefix comes from the functions being declared
> as DLL imported/exported symbols.  So I think you need to go review
> the header files, and fix up some macros in your makefile so that the
> __declspec(dllexport) macros are not used.  (For example, have your
> definition of PTW_EXTERN)

If that's all that's required, I propose to change the following in 
pthread.h:-

#ifdef _DLL
#  ifdef PTW32_BUILD
#    define PTW32_DLLPORT __declspec (dllexport)
#  else
#    define PTW32_DLLPORT __declspec (dllimport)
#  endif
#endif

to:-

#ifndef PTW32_STATIC
#  ifdef PTW32_BUILD
#    define PTW32_DLLPORT __declspec (dllexport)
#  else
#    define PTW32_DLLPORT __declspec (dllimport)
#  endif
#endif

And require that PTW32_STATIC be defined explicitly as a compiler flag 
for both static library build and application build.

Thanks.
Ross

>
> Srdjan wrote:
>
>> Hi,
>>
>> After reading all the readme's and FAQs I still have a bit of a problem
>> linking with pthread for win32. Somebody might have already solved it...
>>
>> Here is the problem....
>>
>> I am porting a small daemon program from linux to win32 (... yes, I
>> know...). Anyway, becasue this little beast is supposed to be used on
>> systems that I am unable to install the pthread.dll, I am trying to 
>> build a
>> static pthread library and link it in with my code.
>>
>> I have fudged building process using VC7.1 (.NET) so it does build a 
>> .lib
>> file, however, when I try linking with my code, I get the following link
>> problems:
>>
>> ============================================================================
>> =============
>> fdca.obj : error LNK2019: unresolved external symbol __imp__pthread_join
>> referenced in function _main
>> fdca.obj : error LNK2019: unresolved external symbol 
>> __imp__pthread_create
>> referenced in function _main
>> fdca_schedule.obj : error LNK2001: unresolved external symbol
>> __imp__pthread_create
>> fdca_collect.obj : error LNK2019: unresolved external symbol
>> __imp__pthread_exit referenced in function _fdca_collect
>> fdca_command.obj : error LNK2019: unresolved external symbol
>> __imp__pthread_exit referenced in function _fdca_command
>> fdca_schedule.obj : error LNK2001: unresolved external symbol
>> __imp__pthread_exit
>> ds.lib(ds.obj) : error LNK2019: unresolved external symbol
>> __imp__pthread_mutex_init referenced in function _ds_list_init
>> ds.lib(ds.obj) : error LNK2019: unresolved external symbol
>> __imp__pthread_mutex_unlock referenced in function _ds_list_insert
>> ds.lib(ds.obj) : error LNK2019: unresolved external symbol
>> __imp__pthread_mutex_lock referenced in function _ds_list_insert
>> .\/winagent.exe : fatal error LNK1120: 7 unresolved externals
>> ============================================================================
>> =============
>>
>> Now, I am sure I have stuffed up something, but I can't figure out what
>> (obvious conclusion :-). My code seems to generate 
>> '__imp__function_name'
>> instead of '_function_name'. I have a number of other external static
>> libraries I am linking with, but they all seem to be linking in happily.
>>
>> The Makefile with nmake builds only a DLL version, and I am trying at 
>> the
>> moment to get it to build a static lib too, but with not much success.
>>
>> I would be ethernally grateful if somebody was able to quickly 
>> identify what
>> I am doing wrong.
>>
>> Cheers,
>>
>> Srdjan
>> Melbourne
>>
>>
>>  
>>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problem linking in pthread librarry.... (Newbie)
  2004-01-08 12:31 Srdjan
@ 2004-01-08 14:34 ` Ed Hume
  2004-01-13  6:11   ` Ross Johnson
  0 siblings, 1 reply; 4+ messages in thread
From: Ed Hume @ 2004-01-08 14:34 UTC (permalink / raw)
  To: Srdjan, pthreads-win32

I believe the __imp__ prefix comes from the functions being declared
as DLL imported/exported symbols.  So I think you need to go review
the header files, and fix up some macros in your makefile so that the
__declspec(dllexport) macros are not used.  (For example, have your
definition of PTW_EXTERN)

Srdjan wrote:

>Hi,
>
>After reading all the readme's and FAQs I still have a bit of a problem
>linking with pthread for win32. Somebody might have already solved it...
>
>Here is the problem....
>
>I am porting a small daemon program from linux to win32 (... yes, I
>know...). Anyway, becasue this little beast is supposed to be used on
>systems that I am unable to install the pthread.dll, I am trying to build a
>static pthread library and link it in with my code.
>
>I have fudged building process using VC7.1 (.NET) so it does build a .lib
>file, however, when I try linking with my code, I get the following link
>problems:
>
>============================================================================
>=============
>fdca.obj : error LNK2019: unresolved external symbol __imp__pthread_join
>referenced in function _main
>fdca.obj : error LNK2019: unresolved external symbol __imp__pthread_create
>referenced in function _main
>fdca_schedule.obj : error LNK2001: unresolved external symbol
>__imp__pthread_create
>fdca_collect.obj : error LNK2019: unresolved external symbol
>__imp__pthread_exit referenced in function _fdca_collect
>fdca_command.obj : error LNK2019: unresolved external symbol
>__imp__pthread_exit referenced in function _fdca_command
>fdca_schedule.obj : error LNK2001: unresolved external symbol
>__imp__pthread_exit
>ds.lib(ds.obj) : error LNK2019: unresolved external symbol
>__imp__pthread_mutex_init referenced in function _ds_list_init
>ds.lib(ds.obj) : error LNK2019: unresolved external symbol
>__imp__pthread_mutex_unlock referenced in function _ds_list_insert
>ds.lib(ds.obj) : error LNK2019: unresolved external symbol
>__imp__pthread_mutex_lock referenced in function _ds_list_insert
>.\/winagent.exe : fatal error LNK1120: 7 unresolved externals
>============================================================================
>=============
>
>Now, I am sure I have stuffed up something, but I can't figure out what
>(obvious conclusion :-). My code seems to generate '__imp__function_name'
>instead of '_function_name'. I have a number of other external static
>libraries I am linking with, but they all seem to be linking in happily.
>
>The Makefile with nmake builds only a DLL version, and I am trying at the
>moment to get it to build a static lib too, but with not much success.
>
>I would be ethernally grateful if somebody was able to quickly identify what
>I am doing wrong.
>
>Cheers,
>
>Srdjan
>Melbourne
>
>
>  
>

-- 
Regards,

Ed Hume
Hume Integration Software           http://www.hume.com/


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Problem linking in pthread librarry.... (Newbie)
@ 2004-01-08 12:31 Srdjan
  2004-01-08 14:34 ` Ed Hume
  0 siblings, 1 reply; 4+ messages in thread
From: Srdjan @ 2004-01-08 12:31 UTC (permalink / raw)
  To: pthreads-win32

Hi,

After reading all the readme's and FAQs I still have a bit of a problem
linking with pthread for win32. Somebody might have already solved it...

Here is the problem....

I am porting a small daemon program from linux to win32 (... yes, I
know...). Anyway, becasue this little beast is supposed to be used on
systems that I am unable to install the pthread.dll, I am trying to build a
static pthread library and link it in with my code.

I have fudged building process using VC7.1 (.NET) so it does build a .lib
file, however, when I try linking with my code, I get the following link
problems:

============================================================================
=============
fdca.obj : error LNK2019: unresolved external symbol __imp__pthread_join
referenced in function _main
fdca.obj : error LNK2019: unresolved external symbol __imp__pthread_create
referenced in function _main
fdca_schedule.obj : error LNK2001: unresolved external symbol
__imp__pthread_create
fdca_collect.obj : error LNK2019: unresolved external symbol
__imp__pthread_exit referenced in function _fdca_collect
fdca_command.obj : error LNK2019: unresolved external symbol
__imp__pthread_exit referenced in function _fdca_command
fdca_schedule.obj : error LNK2001: unresolved external symbol
__imp__pthread_exit
ds.lib(ds.obj) : error LNK2019: unresolved external symbol
__imp__pthread_mutex_init referenced in function _ds_list_init
ds.lib(ds.obj) : error LNK2019: unresolved external symbol
__imp__pthread_mutex_unlock referenced in function _ds_list_insert
ds.lib(ds.obj) : error LNK2019: unresolved external symbol
__imp__pthread_mutex_lock referenced in function _ds_list_insert
.\/winagent.exe : fatal error LNK1120: 7 unresolved externals
============================================================================
=============

Now, I am sure I have stuffed up something, but I can't figure out what
(obvious conclusion :-). My code seems to generate '__imp__function_name'
instead of '_function_name'. I have a number of other external static
libraries I am linking with, but they all seem to be linking in happily.

The Makefile with nmake builds only a DLL version, and I am trying at the
moment to get it to build a static lib too, but with not much success.

I would be ethernally grateful if somebody was able to quickly identify what
I am doing wrong.

Cheers,

Srdjan
Melbourne

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-01-13  6:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-08 13:50 Problem linking in pthread librarry.... (Newbie) Kok YihTzye-CYK011
  -- strict thread matches above, loose matches on Subject: below --
2004-01-08 12:31 Srdjan
2004-01-08 14:34 ` Ed Hume
2004-01-13  6:11   ` Ross Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).