Re: Linking phobos64.lib errors

2023-03-01 Thread Elfstone via Digitalmars-d-learn

On Wednesday, 1 March 2023 at 07:15:36 UTC, Elfstone wrote:

https://forum.dlang.org/post/edwmddiqcsnwpliyo...@forum.dlang.org

On Wednesday, 3 September 2014 at 09:13:52 UTC, Szymon Gatner 
wrote:
On Wednesday, 3 September 2014 at 08:47:35 UTC, Rikki 
Cattermole wrote:

[...]


Hey, for some reason I missed this:

http://forum.dlang.org/thread/ji93fh$15ph$1...@digitalmars.com

The fix is to add main() function to D library. Don't know why 
it is needed for static lib but it sure helps to resolve link 
issues.


Strangely I just got similar link errors (phobos64.lib ... 
unresolved ...) building dynamic lib on Win11 (no errors on 
Win10, or with ldc). I found this thread and adding main() 
saved me.


Any expert can explain why and when main() is needed for 
dynamic, or static lib?


Oh, I'm not saved. Because now I get "only one `main` allowed" 
error when I link the lib.


Linking phobos64.lib errors

2023-02-28 Thread Elfstone via Digitalmars-d-learn

https://forum.dlang.org/post/edwmddiqcsnwpliyo...@forum.dlang.org

On Wednesday, 3 September 2014 at 09:13:52 UTC, Szymon Gatner 
wrote:
On Wednesday, 3 September 2014 at 08:47:35 UTC, Rikki 
Cattermole wrote:

On 3/09/2014 7:22 p.m., Szymon Gatner wrote:

[...]


My gut feeling looking at that, is that its not linking 
against the c runtime.


For reference I'm pretty sure _deh_beg is related to exception 
handling.


Hey, for some reason I missed this:

http://forum.dlang.org/thread/ji93fh$15ph$1...@digitalmars.com

The fix is to add main() function to D library. Don't know why 
it is needed for static lib but it sure helps to resolve link 
issues.


Strangely I just got similar link errors (phobos64.lib ... 
unresolved ...) building dynamic lib on Win11 (no errors on 
Win10, or with ldc). I found this thread and adding main() saved 
me.


Any expert can explain why and when main() is needed for dynamic, 
or static lib?


Re: Linking phobos64.lib errors

2014-09-03 Thread Szymon Gatner via Digitalmars-d-learn
On Wednesday, 3 September 2014 at 08:47:35 UTC, Rikki Cattermole 
wrote:

On 3/09/2014 7:22 p.m., Szymon Gatner wrote:

Hi,

I am trying to make simple x64 C++ application that uses D 
static
library (trying to do "Interfacing with C++" from "D Cookbook" 
chapter).

I am Using Visual Studio 2012 to create main() like this:

#include 

extern "C" int rt_init();
extern "C" void rt_term();
// RAII struct for D runtime initialization and termination
struct DRuntime {
  DRuntime() {
if(!rt_init()) {
  // you could also use an exception
  fprintf(stderr, "D Initialization failed");
  exit(1);
}
  }
  ~DRuntime() {
rt_term();
  }
};

int main()
{
  DRuntime druntime;
}

and then I am just setting linker to link to phobos64.lib but 
I am

getting those:

1>phobos64.lib(dmain2_4ec_2f9.obj) : error LNK2019: unresolved 
external

symbol _deh_beg referenced in function rt_init
1>phobos64.lib(sections_win64_575_4e2.obj) : error LNK2001: 
unresolved

external symbol _deh_beg
1>phobos64.lib(sections_win64_57b_5a5.obj) : error LNK2019: 
unresolved

external symbol _minfo_end referenced in function
_D2rt14sections_win6414getModuleInfosFZAyPS6object10ModuleInfo
1>phobos64.lib(sections_win64_57b_5a5.obj) : error LNK2019: 
unresolved

external symbol _minfo_beg referenced in function
_D2rt14sections_win6414getModuleInfosFZAyPS6object10ModuleInfo
1>phobos64.lib(sections_win64_575_4e2.obj) : error LNK2019: 
unresolved

external symbol _deh_end referenced in function
_D2rt14sections_win6412SectionGroup8ehTablesMxFNdZAyS2rt15deh_win64_posix9FuncTable


What am I doing wrong? Book says that on x64 Windows VC++ can 
be used to

create hybrid application.


My gut feeling looking at that, is that its not linking against 
the c runtime.


For reference I'm pretty sure _deh_beg is related to exception 
handling.


Hey, for some reason I missed this:

http://forum.dlang.org/thread/ji93fh$15ph$1...@digitalmars.com

The fix is to add main() function to D library. Don't know why it 
is needed for static lib but it sure helps to resolve link issues.


Re: Linking phobos64.lib errors

2014-09-03 Thread Rikki Cattermole via Digitalmars-d-learn

On 3/09/2014 7:22 p.m., Szymon Gatner wrote:

Hi,

I am trying to make simple x64 C++ application that uses D static
library (trying to do "Interfacing with C++" from "D Cookbook" chapter).
I am Using Visual Studio 2012 to create main() like this:

#include 

extern "C" int rt_init();
extern "C" void rt_term();
// RAII struct for D runtime initialization and termination
struct DRuntime {
   DRuntime() {
 if(!rt_init()) {
   // you could also use an exception
   fprintf(stderr, "D Initialization failed");
   exit(1);
 }
   }
   ~DRuntime() {
 rt_term();
   }
};

int main()
{
   DRuntime druntime;
}

and then I am just setting linker to link to phobos64.lib but I am
getting those:

1>phobos64.lib(dmain2_4ec_2f9.obj) : error LNK2019: unresolved external
symbol _deh_beg referenced in function rt_init
1>phobos64.lib(sections_win64_575_4e2.obj) : error LNK2001: unresolved
external symbol _deh_beg
1>phobos64.lib(sections_win64_57b_5a5.obj) : error LNK2019: unresolved
external symbol _minfo_end referenced in function
_D2rt14sections_win6414getModuleInfosFZAyPS6object10ModuleInfo
1>phobos64.lib(sections_win64_57b_5a5.obj) : error LNK2019: unresolved
external symbol _minfo_beg referenced in function
_D2rt14sections_win6414getModuleInfosFZAyPS6object10ModuleInfo
1>phobos64.lib(sections_win64_575_4e2.obj) : error LNK2019: unresolved
external symbol _deh_end referenced in function
_D2rt14sections_win6412SectionGroup8ehTablesMxFNdZAyS2rt15deh_win64_posix9FuncTable


What am I doing wrong? Book says that on x64 Windows VC++ can be used to
create hybrid application.


My gut feeling looking at that, is that its not linking against the c 
runtime.


For reference I'm pretty sure _deh_beg is related to exception handling.


Linking phobos64.lib errors

2014-09-03 Thread Szymon Gatner via Digitalmars-d-learn

Hi,

I am trying to make simple x64 C++ application that uses D static 
library (trying to do "Interfacing with C++" from "D Cookbook" 
chapter). I am Using Visual Studio 2012 to create main() like 
this:


#include 

extern "C" int rt_init();
extern "C" void rt_term();
// RAII struct for D runtime initialization and termination
struct DRuntime {
  DRuntime() {
if(!rt_init()) {
  // you could also use an exception
  fprintf(stderr, "D Initialization failed");
  exit(1);
}
  }
  ~DRuntime() {
rt_term();
  }
};

int main()
{
  DRuntime druntime;
}

and then I am just setting linker to link to phobos64.lib but I 
am getting those:


1>phobos64.lib(dmain2_4ec_2f9.obj) : error LNK2019: unresolved 
external symbol _deh_beg referenced in function rt_init
1>phobos64.lib(sections_win64_575_4e2.obj) : error LNK2001: 
unresolved external symbol _deh_beg
1>phobos64.lib(sections_win64_57b_5a5.obj) : error LNK2019: 
unresolved external symbol _minfo_end referenced in function 
_D2rt14sections_win6414getModuleInfosFZAyPS6object10ModuleInfo
1>phobos64.lib(sections_win64_57b_5a5.obj) : error LNK2019: 
unresolved external symbol _minfo_beg referenced in function 
_D2rt14sections_win6414getModuleInfosFZAyPS6object10ModuleInfo
1>phobos64.lib(sections_win64_575_4e2.obj) : error LNK2019: 
unresolved external symbol _deh_end referenced in function 
_D2rt14sections_win6412SectionGroup8ehTablesMxFNdZAyS2rt15deh_win64_posix9FuncTable


What am I doing wrong? Book says that on x64 Windows VC++ can be 
used to create hybrid application.