Unresolved external symbol __DllMainCRTStartup@12


#1

Manifest file not generated for extensions with VC++ 2005 express.
where is my losting?

C:\ext>nmake

Microsoft ® Program Maintenance Utility Version 7.00.8882
Copyright © Microsoft Corp 1988-2000. All rights reserved.

    cl -nologo -LD -FeTest.so test.obj msvcrt-ruby18.lib

oldnames.lib user3
2.lib advapi32.lib wsock32.lib -link -incremental:no -debug -opt:ref
-opt:icf -
dll -libpath:“C:/sdk/Lib/AMD64” -libpath:“C:/sdk/lib”
-libpath:“c:/ruby/lib” -de
f:Test-i386-mswin32.def -implib:Test-i386-mswin32.lib
-pdb:Test-i386-mswin32.pdb

Creating library Test-i386-mswin32.lib and object
Test-i386-mswin32.exp
LINK : error LNK2001: unresolved external symbol __DllMainCRTStartup@12
Test.so : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: ‘cl’ : return code ‘0x2’
Stop.


#2

Hi,

At Sat, 28 Apr 2007 12:21:10 +0900,
Haoqi H. wrote in [ruby-talk:249406]:

Manifest file not generated for extensions with VC++ 2005 express.
where is my losting?

How did you build ruby?

C:\ext>nmake

Microsoft ® Program Maintenance Utility Version 7.00.8882
Copyright © Microsoft Corp 1988-2000. All rights reserved.

    cl -nologo -LD -FeTest.so test.obj msvcrt-ruby18.lib

Seems you use VC6.

oldnames.lib user3
2.lib advapi32.lib wsock32.lib -link -incremental:no -debug -opt:ref
-opt:icf -
dll -libpath:“C:/sdk/Lib/AMD64” -libpath:“C:/sdk/lib”

I don’t know if VC6 supports AMD64, does it?


#3

(1)I try write a ruby extension with code(test.c):
--------------from programming ruby book---------------
#include “ruby.h”

static VALUE t_init(VALUE self)
{
VALUE arr;

arr = rb_ary_new();
rb_iv_set(self, “@arr”, arr);
return self;
}

static VALUE t_add(VALUE self, VALUE anObject)
{
VALUE arr;

arr = rb_iv_get(self, “@arr”);
rb_ary_push(arr, anObject);
return arr;
}

VALUE cTest;

void Init_Test() {
cTest = rb_define_class(“Test”, rb_cObject);
rb_define_method(cTest, “initialize”, t_init, 0);
rb_define_method(cTest, “add”, t_add, 1);
}

(2)extconf.rb:
require ‘mkmf’
dir_config(“test”)
create_makefile(“Test”)

(3)run ruby extconf.rb --with-test-dir=“C:/sdk”
–with-test-lib=“C:/sdk/Lib/AMD64” –
with-test-include=“C:\sdk\Include\crt”

“msvcrt.lib,msvcrtd.lib”, the two files on
“C:/sdk/Lib/AMD64”,“C:/sdk/Lib/IA64”


#4

Oh, I found “C:\Program Files\Microsoft Visual Studio 8\VC\lib” also
have a file “msvcrt.lib,msvcrtd.lib”!


#5

thanks Nobuyoshi N… yes , VC6 does not supports AMD64

(1).I copy all "“C:\Program Files\Microsoft Visual Studio 8\VC\lib”
files to “C:/VClib”

(2).C:\ext>ruby extconf.rb --with-test-dir=“C:/sdk”
–with-test-lib=“C:/VClib” --with-test-include=“C:\sdk\Include\crt”

now, .manifest was created! :slight_smile:


#6

then,I run command:
mt -manifest test.so.manifest -outputresource:test.so;2
nmake install

run test_test.rb:
require “test”

get errors:

c:/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt/test.so: 127: - Init_test
(LoadError)
c:/ruby/lib/ruby/site_ruby/1.8/i386-msvcrt/test.so from
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require’


#7

Oh,yeah,I am successful!
I copy code from
http://www.rubyinside.com/how-to-create-a-ruby-extension-in-c-in-under-5-minutes-100.html
then

(1)ruby extconf.rb --with-mytest-dir=“C:/sdk”
–with-mytest-lib=“C:/VClib” --with-mytest-include=“C:\sdk\Include\crt”

(2)mt -manifest mytest.so.manifest -outputresource:mytest.so;2
(3)require “mytest”
include MyTest
puts test1

get Num “10”,haha,very happy!