[std.process] get Pid class by Process ID?
Hi everyone, Is it possible to get a Pid (class) from a process id (int)?. I need to use the wait function from std.process but it asks for a Pid, and I have only the process id (integer). auto pd = new Pid(processID); // doesn't work I want to verify that the parent process is still alive, if it doesn't, this child process shall be terminated. Currently, I'm passing the parent process ID by arguments and I need a cross-OS way (if possible). Thanks in advance.
Re: what's wrong with my class?
On Thursday, 5 May 2016 at 00:03:34 UTC, Brian Schott wrote: On Wednesday, 4 May 2016 at 23:19:08 UTC, Jonathan Villa wrote: What I'm doing wrong? :< All right. D's type system is marking the `Session` constructor as `shared`. This makes the check `static if (is(typeof(result.__ctor(args` in std.conv.emplace fail because `result` is a non-shared `Session`. `emplace` is used by `make` to actually initialize the memory returned by `malloc`, which is why you care about it here. The solution to this is to tell `make` that you want it to return a `shared Session`. Once you do this the type checks should pass. tldr: `return Mallocator.instance.make!(shared Session)(_parent, id_user);` You're right! the error doesn't show anymore. Just one question about 'shared': That class has an ASI class, should I tag it as 'synchronized' too or it won't be necessary? (because is already inside in a synchronized class) I suppose I should tag it too as synchronized
Re: what's wrong with my class?
On Wednesday, 4 May 2016 at 23:33:28 UTC, Brian Schott wrote: On Wednesday, 4 May 2016 at 23:19:08 UTC, Jonathan Villa wrote: What I'm doing wrong? :< I see that the types of `id_user` aren't necessarily the same between `create` and `this`. Oh, they are indeed same (alias). I wrote uint because I didn't want you to confuse with such a large name and I forgot to change the other one c:
what's wrong with my class?
... import std.experimental.allocator : make, dispose; import std.experimental.allocator.mallocator : Mallocator; public synchronized class Session { private: ASI parent; cUser user; public: static Session create(ASI _parent, accounts.user.id_user_t id_user) @nogc { return Mallocator.instance.make!Session(_parent, id_user); } this (ASI _parent, uint id_user) { assert(_parent !is null); assert(id_user != 0); parent = _parent; user = Mallocator.instance.make!cUser(id_user, parent.stringManager); } ~this () { Mallocator.instance.dispose(user); } } trying to build it throws "Don't know how to initialize an object of type Session with arguments (ASI, uint) D:\Dmd\dmd2\windows\bin\..\..\src\phobos\std\experimental\allocator\package.d(455,48): instantiated from here: emplace!(Session, ASI, uint) source\alfred\memory.d(51,52):instantiated from here: make!(Session, shared(Mallocator), ASI, uint) dmd failed with exit code 1." Can't you see the constructor arguments? x What I'm doing wrong? :<
Re: what is missing here?
On Tuesday, 3 May 2016 at 16:13:07 UTC, ag0aep6g wrote: On 03.05.2016 18:03, Jonathan Villa wrote: Types are not values. You cannot return a type from a function. Use aliases instead: alias user_id_t = typeof(dummy1); alias name_t = typeof(dummy2); /* ... etc ... */ Thank you, I thought alias was just allowed to be declared outside, but declaring them inside as public it now behaves like I want.
what is missing here?
public final class accounts { public: static table_user user; } public final class table_user { private: static uint32 dummy1; static string dummy2; static DateTime dummy3; static ubyte dummy4; public: static @property auto user_id_t() { return typeof(dummy1); } static @property auto name_t() { return typeof(dummy2); } static @property auto alias_t() { return typeof(dummy2);} static @property auto pers_email_t() { return typeof(dummy2); } static @property auto corp_email_t() { return typeof(dummy2); } static @property auto password_t() { return typeof(dummy2); } static @property auto last_login_t() { return typeof(dummy3); } static @property auto active_t() { return typeof(dummy4); } static @property auto id_lang_t() { return typeof(dummy4); } static @property auto function_t() { return typeof(dummy4); } static @property auto register_date_t() { return typeof(dummy3); } } for every property it throws me an error at compile time: type ($) has no value. I'm trying to do a wrap of a database so when getting a resultset using mysql-native I can do result.front()[0].get!(accounts.user.user_it_t); si it's more readable.
Re: Question about dub and imports
On Monday, 18 April 2016 at 21:23:02 UTC, Jonathan Villa wrote: I'm trying to build a vibe.d application, but I made a little library (just source code) that I want to add to the project. [...] Close the question, looks like I found it: importPaths.
Question about dub and imports
I'm trying to build a vibe.d application, but I made a little library (just source code) that I want to add to the project. So, in the generated dub.sdl file I added at the end: sourcePaths "../D/src" sourceFiles "../D/src/alfred/package.d" The problem is at build time DUB tries to create a library file and it fails. I don't want to it to create a .lib file, just "look at this path so when I write `import alfred;` you know where this refers to`. I'm pretty new using the dub thing, I have look in https://code.dlang.org/package-format?lang=sdl but I get a little confused. I have already did this in a non-dub project, adding the import path with -I and listing the files and it never actually generated a lib. Or is there a way to just inject a direct line to the build params like "-I../D/src" alfred/types.d alfred/command.d ...(etc) when running dub in my vibe-d project??? (Is really neccesary to look my little source library like a .lib file and try to generate it?) JV
Re: What is best way to get see function from separate file
On Sunday, 10 April 2016 at 18:57:45 UTC, Suliman wrote: I like it. Am i right understand that it prevent creation unneeded of new instance of logger? No, you need to pass a valid instance in foo(...), It should have been created before the call to foo(...). I prefer the second way (separate file of the fLogger variable) so you can use any time, everywhere just adding the import using just one instance. If you want create an instance every time you get to foo() and without the need of an argument, just import the logger library: import std.experimental.logger; //here foo() { auto log = new FileLogger("ErrorLog.txt"); ... destroy(log); } And what problems I can get if I will create new instance of logger in every stand alone function? Just resource overusage? I don't know how exactly FileLogger works, if it need some kind of close() function like normal files or it open the file ... write on it ... and after that it close the file. But the basic thing is ... yes, allocatin and deallocating an instance everytime you are going to use it. JV.
Re: What is best way to get see function from separate file
On Sunday, 10 April 2016 at 18:26:57 UTC, Suliman wrote: Sorry for wrong posting! I have got logger instance in App.d void main() { ... FileLogger fLogger = new FileLogger("ErrorLog.txt"); foo(); } utils.d: foo() { // I need logging here } Also I have file utils.d that include stand-alone functions that is not in classes. In one of them I need to implement logging. What is the best way to do it. I see only two way -- create new Loggining instance. And second -- to import App.d as module, because without importing I would not able to see Logger instance. But both of this way is look ugly. Is there any best solution? You could pass an argument of type FileLogger (probably better a pointer?) foo ( FileLogger log ) { } Other whay is to leave FileLogger instance in a separated module: logger.d public static FileLogger fLogger; App.d import logger; //the module void main() { // generate instance logger = new FileLogger("ErrorLog.txt"); } utils.d import logger; // the module foo () { fLogger... } I cannot think in other ways. JV
Re: What is best way to get see function from separate file
On Sunday, 10 April 2016 at 18:36:19 UTC, Jonathan Villa wrote: On Sunday, 10 April 2016 at 18:26:57 UTC, Suliman wrote: Other whay is to leave FileLogger instance in a separated module: logger.d public static FileLogger fLogger; App.d import logger; //the module void main() { // generate instance logger = new FileLogger("ErrorLog.txt"); } utils.d import logger; // the module foo () { fLogger... } I cannot think in other ways. JV FIXING MAIN() void main() { // generate instance fLogger = new FileLogger("ErrorLog.txt"); }
Re: Best properly way to destroy a 2 dimensional array?
On Friday, 8 April 2016 at 15:21:50 UTC, Steven Schveighoffer wrote: On 4/8/16 11:08 AM, Jonathan Villa wrote: On Thursday, 7 April 2016 at 16:13:59 UTC, Steven Schveighoffer wrote: Your best bet is to free the memory itself if it's possible. import core.memory: GC; GC.free(combs.ptr); For more info on how GC works: dlang.org/spec/garbage.html -Steve Thank you very much! I think this is the answer I was looking for C: JV
Re: Best properly way to destroy a 2 dimensional array?
On Thursday, 7 April 2016 at 16:13:59 UTC, Steven Schveighoffer wrote: On 4/6/16 3:54 PM, Jonathan Villa wrote: You are likely running into the GC being conservative. You are also possibly running into an issue where you are expecting the compiler to do something with the stack where it may do something else. A classic question that is asked on D forums all the time is why when you null some variable and then call GC collect, the memory isn't collected. The answer is because quite possibly the value is still in a register, and the registers must be scanned too. As for conservatism, if you generate a 1-million element array of pointers (each element has a pointer in it), then you have some random stack variable that "happens" to point into that giant array (more likely in 32-bit systems), then both the array, and all it's pointing at gets saved. -Steve Good, I compiled the program in 64 bit mode (-m64) and now it release memory normally like in Debian. I would like to know where can I learn more about the 'register' or the GC for the D so I can avoid future issues. JV.
Re: Best properly way to destroy a 2 dimensional array?
On Thursday, 7 April 2016 at 10:05:02 UTC, Andrea Fontana wrote: On Thursday, 7 April 2016 at 10:02:05 UTC, Andrea Fontana wrote: On Wednesday, 6 April 2016 at 20:30:33 UTC, Jonathan Villa wrote: Anything change if you wrap your code like: while ... { ... { ubyte[][] ... ... } GC.collect(); GC.minimieze(); } ? Or maybe you could try to do: combs = null; before collecting. Yep, I enclosed the ubyte[][] allocation in a new scope, like our friend Alex suggested, but nothing seems to change. I'm going to try combs = null... Big news, I've tested my code using Debian x64 8.2 and it really frees memory! even without adding `combs = null` (I'm going to add it anyway just in case). So, looks like is some kind of Windows plataform problem. Next time I boot on Windows I'm going to add the null assignment and hope for results. Regards!
Re: Best properly way to destroy a 2 dimensional array?
On Wednesday, 6 April 2016 at 21:33:14 UTC, Alex Parrill wrote: On Wednesday, 6 April 2016 at 19:54:32 UTC, Jonathan Villa wrote: I wrote a little program that given some number it generates a ... Why not make a range instead? No need to reserve memory for the entire array if you can compute the elements as-needed. If you really want an array, std.experimental.allocator will let you manually allocate/release objects. I'm going to try use a custom allocator for tomorrow. My general idea is first to get the predicted quantity of combinations so I can divide and parallelize them. What do you think can be the problem with the lack of deallocation? Regards.
Re: Best properly way to destroy a 2 dimensional array?
On Wednesday, 6 April 2016 at 19:54:32 UTC, Jonathan Villa wrote: I wrote a little program that given some number it generates a TL;DR: My program generates a very large `ubyte[][]`, and after I call destroy and GC.collect() and GC.minimize(), the memory occuping doesn't seems to decrease.
Re: Best properly way to destroy a 2 dimensional array?
On Wednesday, 6 April 2016 at 19:54:32 UTC, Jonathan Villa wrote: I wrote a little program that given some number it generates a list of different combinations (represented by a ubyte array), so in the end my function with name GenerateCombinations(int x) returns a ubyte[][] (list of arrays of ubytes). Sample code. void main() { while(true) { write("Alternatives quantity: "); string value = chomp(readln()); if (value == "x") break; int x = to!int(value); ubyte[][] combs = GenerateCombinations(x); writefln("There are %d combinations.", combs.length); foreach(ubyte[] a; combs) destroy(a); destroy(combs); writeln(); GC.collect(); GC.minimize(); } return; }
Best properly way to destroy a 2 dimensional array?
I wrote a little program that given some number it generates a list of different combinations (represented by a ubyte array), so in the end my function with name GenerateCombinations(int x) returns a ubyte[][] (list of arrays of ubytes). Now the problem is, the quantity of combinations generated are pow(2, `x`), thus, giving 20 it returns me a list of 1_048_576 arrays of ubyte, every array has length of `x` so, in the end this function allocates (seeing the Windows Task Manager) 42 MB of data after input `20` the first time. When the list is ready it prints the quantity of combinations given (combinations.length), after that I added a foreach(ubyte[] a; combinations) calling destroy to every array and then destroy(combinations), and before to re-input a new number to generate a new combination list I call GC.Collect() and GC.minimize(). My question is if I'm doing good calling destroy to those arrays, because I don't see any change in the quantity of memory the program is using: In the start it uses 1496 KB, after input `20` it now have 43000 KB (approx.) and if I input again 20 then it sums up to 9 KB. In the end I don't see some kind of real memory free. I'm doing something wrong? That's the reason I'm asking for your advice. PD: All arrays are constructed with the `new` expression. PD2: Don't ask me why I don't better do an `int count` instead of constructing arrays, this little program is going to be part of a more huge application and I need the combination list. Regards. JV
Re: Strange behavior in console with UTF-8
On Monday, 28 March 2016 at 18:28:33 UTC, Steven Schveighoffer wrote: On 3/27/16 12:04 PM, Jonathan Villa wrote: I can reproduce your issue on windows. It works on Mac OS X. I see different behavior on 32-bit (DMC stdlib) vs. 64-bit (MSVC stdlib). On both, the line is not read properly (I get a length of 0). On 32-bit, the program exits immediately, indicating it cannot read any more data. On 64-bit, the program continues to allow input. I don't think this is normal behavior, and should be filed as a bug. I'm not a Windows developer normally, but I would guess this is an issue with the Windows flavors of readln. Please file here: https://issues.dlang.org under the Phobos component. -Steve Ok, I'm gonna register it with your data. Thanks. JV.
Re: Strange behavior in console with UTF-8
On Saturday, 26 March 2016 at 16:34:34 UTC, Steven Schveighoffer wrote: On 3/25/16 6:47 PM, Jonathan Villa wrote: At this point, I think knowing exactly what input you are sending would be helpful. Can you attach a file which has the input that causes the error? Or just paste the input into your post. -Steve I've tested on Debian 4.2 x64 using CHAR type, and it behaves correctly without any problems. Clearly this bug must be something related with the Windows console. Here's the behaviour in Windows 10 x64: http://prntscr.com/akskt1 And here's in Debian x64 4.2: http://prntscr.com/akskjw JV
Re: Strange behavior in console with UTF-8
On Saturday, 26 March 2016 at 16:34:34 UTC, Steven Schveighoffer wrote: On 3/25/16 6:47 PM, Jonathan Villa wrote: On Friday, 25 March 2016 at 13:58:44 UTC, Steven Schveighoffer wrote: [...] OK, the following inputs I've tested: á, é, í, ó, ú, ñ, à, è, ì, ò, ù. Just one input is enough to reproduce the behaviour. JV It's the same Ali suggested (if I get it right) and the behaviour its the same. It just get to send a UTF8 char to reproduce the mess, independently of the char type you send. At this point, I think knowing exactly what input you are sending would be helpful. Can you attach a file which has the input that causes the error? Or just paste the input into your post. -Steve The following chars I've tested: á, é, í, ó, ú, ñ, à, è, ì, ò, ù. Just one input of thouse is enough to reproduce the behaviour
Re: Strange behavior in console with UTF-8
On Friday, 25 March 2016 at 13:58:44 UTC, Steven Schveighoffer wrote: On 3/24/16 8:54 PM, Jonathan Villa wrote: [...] D's File i/o uses C's FILE * i/o system. At least on Windows, this has literally zero support for wchar (you can set stream width, and the library just ignores it). What is likely happening is that it is putting the char code units into wchar buffer directly, which is not what you want. I am not certain of this cause, but I would steer clear of any i/o that is not char-based. What you can do is read into a char buffer, and then re-encode using std.conv.to to get wchar strings if you need that. -Steve It's the same Ali suggested (if I get it right) and the behaviour its the same. It just get to send a UTF8 char to reproduce the mess, independently of the char type you send. JV
Re: Strange behavior in console with UTF-8
On Friday, 25 March 2016 at 01:03:06 UTC, Ali Çehreli wrote: > Try char: char[] readerBuffer; Ali Also tried with dchar ... there's no changes.
Re: Strange behavior in console with UTF-8
On Friday, 25 March 2016 at 01:03:06 UTC, Ali Çehreli wrote: On 03/24/2016 05:54 PM, Jonathan Villa wrote: Try char: char[] readerBuffer; flush() has no effect on input streams. Ali Thankf fot he quick reply. Unfortunately it behaves exactly as before with wchar.
Strange behavior in console with UTF-8
I prefer to post this thing here because it could that I'm doing something wrong. I'm using std.stdio -> readln() to read whatever I'm typing in the console. BUT, if the line contains some UTF-8 characters, the data obtained is EMPTY and module runnable; import std.stdio; import std.string : chomp; import std.experimental.logger; void doSomethingElse(wchar[] data) { writeln("hello!"); } int main(string[] args) { /* Some fix I found to fix UTF-8 related problems, I'm using Windows 10 */ version(Windows) { import core.sys.windows.windows; if (SetConsoleCP(65001) == 0) throw new Exception("failure"); if (SetConsoleOutputCP(65001) == 0) throw new Exception("failure"); } FileLogger fl = new FileLogger("log.log"); wchar[] readerBuffer; readln(readerBuffer); readerBuffer = chomp(readerBuffer); fl.info(readerBuffer.length); /* <- if the readed string contains at least one UTF-8 char this prints 0, else it prints its length */ if (readerBuffer != "exit"w) doSomethingElse(readerBuffer); /* Also, all the following code doesn't run as expected, the program doesn't wait for you, it executes readln() even without pressing/sending a key */ readln(readerBuffer); fl.info(readerBuffer.length); readln(readerBuffer); fl.info(readerBuffer.length); readln(readerBuffer); fl.info(readerBuffer.length); readln(readerBuffer); fl.info(readerBuffer.length); readln(readerBuffer); fl.info(readerBuffer.length); return 0; } The real code is bigger but this describes the bug. Also, if it needs to print UTF-8 there's no problem. My main problem is that the line is gonna be sended through a TCP socket and I wanna make it work with UTF-8. I'm using WCHAR instead of CHAR with the hope to get less problems in the future. I you comment the fixed Windows code, the program crashes http://prntscr.com/ajmy14 Also I tried stdin.flush() right after the first readln() but nothing seems to fix it. I'm doing something wrong? many thanks.
issue importing std.file or std.stdio on win x64 build.
Hello, I've been trying to program and app that writes its own log, so, to deal with files I tried using std.file. But with just adding the import std.file; it throws me (AFAIK) a link error: (some texts are in spanish, I tried to translate the important thing) Building Release\ASI.exe... libucrt.lib(fgetc.obj) : error LNK2005: already defined _fgetc_nolock in phobos64.lib(stdio_374_54d.obj) phobos64.lib(stdio_374_54d.obj) : error LNK2019: extern symbol _filbuf [unresolved referred in the function] _fgetc_nolock Release\ASI.exe : fatal error LNK1120: 1 externos sin resolver Building Release\ASI.exe failed! This only happens with x64 build, in x86 works fine, but I want to stick with x64 as much as possible. So I did some research to get some kind of alternative and I found that std.stdio has a File class to work with, I implemented it, but now throws me the following: (some texts are in spanish, I tried to translate the important thing) Building Release\ASI.exe... phobos64.lib(stdio_373_566.obj) : error LNK2019: extern symbol _flsbuf [unresolved referred in the function] _fputc_nolock Release\ASI.exe : fatal error LNK1120: 1 externos sin resolver Building Release\ASI.exe failed! I did some research again, and the _flsbuf function is in: https://github.com/D-Programming-Language/druntime/blob/6f6ec7f4706b128bffaefe9145bec9581e2e7d39/src/rt/msvc.c at line 94. _fgetc_nolock is in msvc.c (druntime) and std/stdio.d as well (phobos lib). What can I do to resolve this issue? Using std.stdio looks like it should be easier to resolve, BUT in the future I want to implement some file/directory management and std.file can do that job, so advices to get rid of the first problem would be my first priority. I'm using VisualD 0.3.43 on Visual Studio Community 2015. Any kind of advice will be appreciated. Thanks.
Re: need help with Windows CreateNamedPipe Security attributes process with undefined symbols at compile time
On Tuesday, 1 December 2015 at 14:48:37 UTC, Adam D. Ruppe wrote: On Tuesday, 1 December 2015 at 14:40:38 UTC, Jonathan Villa wrote: MAN! what the heck? I changed the build from x86 to x64 and there's no more errors. Even without the new pragma line. Either way I would prefer x64 over x86. 64 bit should work better because then it uses the linker and dll definitions from Microsoft, which are more up to date. The ones that come with 32 bit dmd are ancient... like Windows 2000ish. We've known about this for ages but nobody has updated them Ok, I'm fine with it; I'm gonna stick with x64, It looks like the better option. Thanks all for your help ^^
Re: need help with Windows CreateNamedPipe Security attributes process with undefined symbols at compile time
On Tuesday, 1 December 2015 at 05:26:25 UTC, Nicholas Wilson wrote: What is causing this: Is this a compile or a linker error? this is the real output of the error: Building Debug\ASI.exe... OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html Debug\ASI.obj(ASI) Error 42: Symbol Undefined _SetSecurityDescriptorDacl@16 Debug\ASI.obj(ASI) Error 42: Symbol Undefined _InitializeSecurityDescriptor@8 Building Debug\ASI.exe failed! is the cast necessary? I tried without the cast and it throws me a compile error, so I made the cast. you want toStringz(pipename) or if you know pipename is a null terminated string pipename.ptr Thanks for your advice, I'm very noob with D so I downloaded the new book that came out that can be free. It's supposed that the name will come in the arguments (I've not written that yet, I did just put some basic string "pipechanneltest" <-string literal. pragma(lib ,"advapi32"); it may also require the appropriate file suffix (.dll or .lib) Yes, I wrote it with comma, it was just a typo error. advapi32.lib I found it in my DMD installation folder (dmd2/windows/lib) (62.5K), same as kernel32.lib (106K). Can I use .lib files from my Windows SDK? it's heavier (189K). I wrote after the pragma(lib ,"kernel32"); the following line: pragma(lib, "advapi32.lib"); I tried without file suffix and with .dll suffix and it failed in all cases. MAN! what the heck? I changed the build from x86 to x64 and there's no more errors. Even without the new pragma line. Either way I would prefer x64 over x86.
need help with Windows CreateNamedPipe Security attributes process with undefined symbols at compile time
Hi, I've been trying to create a NamedPipe with security attributes but at compile time throws: Error 42: Symbol Undefined _InitializeSecurityDescriptor@8 Error 42: Symbol Undefined _SetSecurityDescriptorDacl@16 This is my code, I'm trying to do it using a class: module asi.pipe; import core.sys.windows.windows; import core.sys.windows.winbase; import core.stdc.stdlib; class Pipe { private HANDLE hPipe; private SECURITY_ATTRIBUTES sa; this(string name) { CreatePipe(name); } private void CreatePipe(string pipename) { sa.lpSecurityDescriptor = malloc(SECURITY_DESCRIPTOR.sizeof); InitializeSecurityDescriptor(cast(PSECURITY_DESCRIPTOR)sa.lpSecurityDescriptor, 1); SetSecurityDescriptorDacl(cast(PSECURITY_DESCRIPTOR)sa.lpSecurityDescriptor, TRUE, cast(ACL*)0, FALSE); sa.nLength = sa.sizeof; sa.bInheritHandle = TRUE; CreateNamedPipeA(cast(char*)pipename, PIPE_ACCESS_DUPLEX, (PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT), PIPE_UNLIMITED_INSTANCES, 4096, 1536, 0, &sa); } } Additional Info: The installer came with just a few files to handle with Windows, comparing the the huge files that are in the repository of druntime: https://github.com/D-Programming-Language/druntime/tree/master/src/core/sys/windows So I renamed the old import to Windows2 and copied this whole github/windows folder there and used its winbase.d because there are the functions definitions that I needed. This functions that throw me errors belongs to the advapi32.dll file. I tried to add pragma(lib "advapi32"); but it didn't work. I'm new/noob dealing with D and I would appreciate any help. thanks.
Re: compilation issues in a shared library project
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 ^^
Re: compilation issues in a shared library project
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 :)
Re: compilation issues in a shared library project
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.
Re: compilation issues in a shared library project
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\Release\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.
compilation issues in a shared library project
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: 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.