www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - compilation issues in a shared library project

reply "Jonathan Villa" <jv_vortex msn.com> writes:
Hello everyone!

I've been starting to use D but some compilation issues appears.
The proyect is just a class library made in Xamarin Studio and 
just contains 3 classes.

At compilation time it throws 7 errors:
Error: object.Object.opEquals could not be resolved - library 
reference missing?
Error: object.Object.opCmp could not be resolved - library 
reference missing?
Error: <log analysis error> Se produjo una excepción de tipo 
'System.OutOfMemoryException'. could not be resolved - library 
reference missing?
Error: object.Object.toString could not be resolved - library 
reference missing?
Error: Object could not be resolved - library reference missing?
Error: TypeInfo_Class.__vtbl could not be resolved - library 
reference missing?
Error: _d_newclass could not be resolved - library reference 
missing?

So, I tested commenting the 2 major classes and left just the 
basic one in order to try if it's something from the 2 majors. 
But the errors persists WITHOUT the last error in the list above.

There must be something that I'm missing.

Here is the code that defines my basic class:

module dt2.DataBlock;

class DataBlock
{
	public DataBlock * NextBlock;
	public DataBlock * PrevBlock;
	public string value;

	this()
	{
		NextBlock = null;
		PrevBlock = null;
		value = null;
	}

	this(string newvalue)
	{
		this();
		value = newvalue;
	}

	~this()
	{
		value = "";
	}
}

AFAIK the Object type (from the Errors) is the base inheritance 
from classes, but in the Object module is implicitly imported 
(according to the documentation in 
http://dlang.org/phobos/object.html)

The project is shared library type. I tried to copy/paste this 
class definition in a console application and it don't throw 
errors.

Any suggestion? Thank you in advice.
Jun 06 2015
next sibling parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 06/06/2015 05:38 PM, Jonathan Villa wrote:

 Hello everyone!

 I've been starting to use D but some compilation issues appears.
 The proyect is just a class library made in Xamarin Studio and just
 contains 3 classes.

 At compilation time it throws 7 errors:
 Error: object.Object.opEquals could not be resolved - library reference
 missing?
Could it be a linking issue? What is the exact compilation line (and the linking line, if separate)? Ali
Jun 07 2015
next sibling parent reply "Jonathan Villa" <jv_vortex msn.com> writes:
On Sunday, 7 June 2015 at 19:17:51 UTC, Ali Çehreli wrote:

 Could it be a linking issue? What is the exact compilation line 
 (and the linking line, if separate)?

 Ali
Compilation line: Current dictionary: C:\Users\JVortex\Documents\Projects\DataTable2 dmd.exe -O -release "DataBlockHeader.d" "DataBlock.d" "DataTable2.d" "-L/IMPLIB:C:\Users\JVortex\Documents\Projects\DataTable2\bin\Rel ase\DataTable2.lib" "-odobj\Release" "-ofC:\Users\JVortex\Documents\Projects\DataTable2\bin\Release\DataTable2.dll" -w -vcolumns OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html obj\Release\DataTable2.obj(DataTable2) Error 42: Symbol Undefined _D6Object7__ClassZ obj\Release\DataTable2.obj(DataTable2) Error 42: Symbol Undefined _D14TypeInfo_Class6__vtblZ obj\Release\DataTable2.obj(DataTable2) Error 42: Symbol Undefined __d_newclass obj\Release\DataTable2.obj(DataTable2) Error 42: Symbol Undefined _D6object6Object6toHashMFNbNeZk obj\Release\DataTable2.obj(DataTable2) Error 42: Symbol Undefined _D6object6Object8opEqualsMFC6ObjectZb obj\Release\DataTable2.obj(DataTable2) Error 42: Symbol Undefined _D6object6Object5opCmpMFC6ObjectZi obj\Release\DataTable2.obj(DataTable2) Error 42: Symbol Undefined _D6object6Object8toStringMFZAya --- errorlevel 7 Exit code 7 In Xamarin Studio there's some linking info in Options->Compiling->Linking: Config: Release; Platform: Any CPU. Output Dir: bin\Release Compile target: Shared library Output file: DataTable2 Libraries: (empty) (NOT CHECKED) Link in static/shared libraries from nested dependencies Additional linking options: (empty) Is that the info you're asking for? If not, please tell me.
Jun 07 2015
next sibling parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 06/07/2015 02:11 PM, Jonathan Villa wrote:

 Is that the info you're asking for? If not, please tell me.
Yes, that's the info people who will help you are looking for. (I don't know the answer. :) ) Ali
Jun 07 2015
prev sibling parent reply "Benjamin Thaut" <code benjamin-thaut.de> writes:
On Sunday, 7 June 2015 at 21:11:38 UTC, Jonathan Villa wrote:
 Compilation line:

 Current dictionary: 
 C:\Users\JVortex\Documents\Projects\DataTable2
 dmd.exe -O -release "DataBlockHeader.d" "DataBlock.d" 
 "DataTable2.d"   
 "-L/IMPLIB:C:\Users\JVortex\Documents\Projects\DataTable2\bin\Rel
ase\DataTable2.lib" 
 "-odobj\Release" 
 "-ofC:\Users\JVortex\Documents\Projects\DataTable2\bin\Release\DataTable2.dll" 
 -w -vcolumns

 Is that the info you're asking for? If not, please tell me.
Shared libraries (DLLs) don't work on windows. They only work for the simplest of all cases (e.g. global functions) and even then there are pitfalls. Just don't do it. The only viable option currently is to link statically or put _all_ your D code into one single Dll and use that Dll from C. Any other use case is bound to fail. I'm currently working on propper dll support for D but it is a lot of work. Kind Regards Benjamin Thaut
Jun 09 2015
parent "Jonathan Villa" <jv_vortex msn.com> writes:
On Tuesday, 9 June 2015 at 14:30:24 UTC, Benjamin Thaut wrote:

 Shared libraries (DLLs) don't work on windows. They only work 
 for the simplest of all cases (e.g. global functions) and even 
 then there are pitfalls. Just don't do it. The only viable 
 option currently is to link statically or put _all_ your D code 
 into one single Dll and use that Dll from C. Any other use case 
 is bound to fail. I'm currently working on propper dll support 
 for D but it is a lot of work.

 Kind Regards
 Benjamin Thaut
ah ok, thank you very much for the advise :)
Jun 14 2015
prev sibling parent "Jonathan Villa" <jv_vortex msn.com> writes:
On Sunday, 7 June 2015 at 19:17:51 UTC, Ali Çehreli wrote:
 On 06/06/2015 05:38 PM, Jonathan Villa wrote:

 (and the linking line, if separate)?

 Ali
I did a little research, and I think you're looking for a line like: link.exe .... there isn't a link.exe call at compilation time.
Jun 07 2015
prev sibling parent reply "Nicholas Wilson" <iamthewilsonator hotmail.com> writes:
On Sunday, 7 June 2015 at 00:38:17 UTC, Jonathan Villa wrote:

 module dt2.DataBlock;

 class DataBlock
 {
 	public DataBlock * NextBlock;
 	public DataBlock * PrevBlock;
 	public string value;

 	this()
 	{
 		NextBlock = null;
 		PrevBlock = null;
 		value = null;
 	}

 	this(string newvalue)
 	{
 		this();
 		value = newvalue;
 	}

 	~this()
 	{
 		value = "";
 	}
 }
Just an FYI classes are reference types in D so you probably meant public DataBlock NextBlock; // is a class reference public DataBlock * PrevBlock; //classes are reference types already no need for * // is a pointer to a class reference
Jun 14 2015
parent "Jonathan Villa" <jv_vortex msn.com> writes:
On Monday, 15 June 2015 at 06:39:49 UTC, Nicholas Wilson wrote:
 On Sunday, 7 June 2015 at 00:38:17 UTC, Jonathan Villa wrote:


 Just an FYI classes are reference types in D so you probably 
 meant

 	public DataBlock NextBlock;	// is a class reference

  	public DataBlock * PrevBlock; 	//classes are reference types 
 already no need for *
 							// is a pointer to a class reference
I didn't know D: thanks so much ^^
Jun 15 2015