www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - The order of libraries makes error in dub

reply unDEFER <undefer gmail.com> writes:
Hello, dub makes string like the next to compile my program 
(WS_32.LIB at the beginning):

$ dmd -m32mscoff -lib 
-of.dub\\build\\library-debug-windows-x86-dmd_2072-83D2723917096513EB36
761C22DDD87\\db.lib -debug -g -w -version=Have_bdb2d WS_32.LIB libdb53d.lib
source/berkeleydb/* -vcolumns
Error: Error reading file 'WS_32.LIB'

So it shows error.

In other order (libraries at the end):
$ dmd -m32mscoff -lib 
-of.dub\\build\\library-debug-windows-x86-dmd_2072-83D2723917096513EB36
761C22DDD87\\db.lib -debug -g -w -version=Have_bdb2d -Isource
source/berkeleydb/* libdb53sd.lib WS2_32.LIB -vcolumns

No error.

But (again WS_32.LIB at beginning):
$ dmd -m32mscoff WS2_32.LIB libdb53sd.lib 
transactions_test/writer source/berkeleydb/*
LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use 
of other libs; use /NODEFAULTLIB:library

Again no error, only warning.

How to make with dub correct compilable compile line?

my dub.json:
=======================================
{
     "name": "bdb2d",
     "targetName": "db",
     "targetType": "library",
     "description": "BerkeleyDB to D bindings.",
     "authors": ["Nikolay (unDEFER) Krivchenkov"],
     "homepage": "http://unde.su",
     "license": "GPL-3.0 or later",
     "libs-posix": ["db"],
     "sourceFiles-windows-dmd": ["libdb53d.lib", "WS_32.LIB"],
     "dflags-windows": ["-m32mscoff"],

     "subPackages": [
         {
             "name": "reader",
             "description": "BerkeleyDB Transaction test. Reader",
             "targetName": "reader",
             "targetType": "executable",
             "sourceFiles": ["transactions_test/reader.d"],
             "targetPath": "transactions_test",
             "dependencies": {
                 "bdb2d": "*"
             }
         }, {
             "name": "writer",
             "description": "BerkeleyDB Transaction test. Writer",
             "targetName": "writer",
             "targetType": "executable",
             "sourceFiles": ["transactions_test/writer.d"],
             "targetPath": "transactions_test",
             "dependencies": {
                 "bdb2d": "*"
             }
         }
     ]
}
==========================================
Dec 05 2016
parent reply unDEFER <undefer gmail.com> writes:
On Monday, 5 December 2016 at 11:51:52 UTC, unDEFER wrote:

     "libs-posix": ["db"],
     "sourceFiles-windows-dmd": ["libdb53d.lib", "WS_32.LIB"],
     "dflags-windows": ["-m32mscoff"],

     "subPackages": [
.... I understand that I don't must add "sourceFiles-windows-dmd" to lib project, I must add it to subPackages, but dub places the names of lib BEFORE -m32mscoff. So it doesn't work. Say me: dub for windows not ready??
Dec 05 2016
parent reply Mike Parker <aldacron gmail.com> writes:
On Monday, 5 December 2016 at 14:29:42 UTC, unDEFER wrote:
 On Monday, 5 December 2016 at 11:51:52 UTC, unDEFER wrote:

     "libs-posix": ["db"],
     "sourceFiles-windows-dmd": ["libdb53d.lib", "WS_32.LIB"],
     "dflags-windows": ["-m32mscoff"],

     "subPackages": [
.... I understand that I don't must add "sourceFiles-windows-dmd" to lib project, I must add it to subPackages, but dub places the names of lib BEFORE -m32mscoff. So it doesn't work. Say me: dub for windows not ready??
DUB works on Windows just fine. My question is, why are you passing libraries in the sourceFiles field? Why not: "libs-windows-dmd":["libdb53d.lib","ws2_32.lib"] Does that make a difference? Also, let's be clear here, the errors you saw above are linker errors, not DUB errors. This one in particular is very common on Windows when using the MS linker: warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library It's normally because you're linking in libs compiled against different versions of the C standard library. Google should help you out there.
Dec 05 2016
next sibling parent rikki cattermole <rikki cattermole.co.nz> writes:
On 06/12/2016 3:59 AM, Mike Parker wrote:

snip

 Also, let's be clear here, the errors you saw above are linker errors,
 not DUB errors. This one in particular is very common on Windows when
 using the MS linker:

 warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs;
 use /NODEFAULTLIB:library

 It's normally because you're linking in libs compiled against different
 versions of the C standard library. Google should help you out there.
Or in unDEFERS case, Cygwin and dmc's (which is 100% against Cygwin's design).
Dec 05 2016
prev sibling parent reply unDEFER <undefer gmail.com> writes:
On Monday, 5 December 2016 at 14:59:26 UTC, Mike Parker wrote:
 "libs-windows-dmd":["libdb53d.lib","ws2_32.lib"]
I have used "sourceFiles-windows-dmd", because it is the single that I could find. Thank you, "libs-windows-dmd":["libdb53d","WS2_32"] works much better, but again these errors: 1) Its put to linker command "db.lib" from libs-posix 2) Its put to linker command at the first "libdb53d.lib WS2_32.lib" and AFTER that -m32mscoff. As result "cannot open file".
Dec 05 2016
parent unDEFER <undefer gmail.com> writes:
On Monday, 5 December 2016 at 15:16:27 UTC, unDEFER wrote:
 2) Its put to linker command at the first "libdb53d.lib 
 WS2_32.lib" and AFTER that -m32mscoff. As result "cannot open 
 file".
Oh, the reason was mistype. And I have found how-to hide linker warning ("lflags-windows": ["/NODEFAULTLIB:LIBCMTD"]). Full correct dub.json: =================================================== { "name": "bdb2d", "targetName": "db", "targetType": "library", "description": "BerkeleyDB to D bindings.", "authors": ["Nikolay (unDEFER) Krivchenkov"], "homepage": "http://unde.su", "license": "GPL-3.0 or later", "libs-posix": ["db"], "libs-windows-dmd": ["libdb53sd", "WS2_32"], "dflags-windows": ["-m32mscoff"], "lflags-windows": ["/NODEFAULTLIB:LIBCMTD"], "subPackages": [ { "name": "reader", "description": "BerkeleyDB Transaction test. Reader", "targetName": "reader", "targetType": "executable", "sourceFiles": ["transactions_test/reader.d"], "targetPath": "transactions_test", "dependencies": { "bdb2d": "*" } }, { "name": "writer", "description": "BerkeleyDB Transaction test. Writer", "targetName": "writer", "targetType": "executable", "sourceFiles": ["transactions_test/writer.d"], "targetPath": "transactions_test", "dependencies": { "bdb2d": "*" } } ] } ==================================================== Thank you to all, the thread is closed.
Dec 05 2016