Forum: Ruby unresolved external symbol __DllMainCRTStartup@12

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C2d178e0b16712c96db70c56095466a9?d=identicon&s=25 Haoqi Haoqi (haoqi)
on 2007-04-28 05:21
Manifest file not generated for extensions with VC++ 2005 express.
where is my losting?

C:\ext>nmake

Microsoft (R) Program Maintenance Utility   Version 7.00.8882
Copyright (C) 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.
F1d6cc2b735bfd82c8773172da2aeab9?d=identicon&s=25 Nobuyoshi Nakada (Guest)
on 2007-04-28 16:03
(Received via mailing list)
Hi,

At Sat, 28 Apr 2007 12:21:10 +0900,
Haoqi Haoqi 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 (R) Program Maintenance Utility   Version 7.00.8882
> Copyright (C) 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?
C2d178e0b16712c96db70c56095466a9?d=identicon&s=25 Haoqi Haoqi (haoqi)
on 2007-04-29 02:55
(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"
C2d178e0b16712c96db70c56095466a9?d=identicon&s=25 Haoqi Haoqi (haoqi)
on 2007-04-29 03:01
Oh, I found "C:\Program Files\Microsoft Visual Studio 8\VC\lib" also
have a file "msvcrt.lib,msvcrtd.lib"!
C2d178e0b16712c96db70c56095466a9?d=identicon&s=25 Haoqi Haoqi (haoqi)
on 2007-04-29 03:20
thanks  Nobuyoshi Nakada. 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! ^_^
C2d178e0b16712c96db70c56095466a9?d=identicon&s=25 Haoqi Haoqi (haoqi)
on 2007-04-29 03:28
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'
C2d178e0b16712c96db70c56095466a9?d=identicon&s=25 Haoqi Haoqi (haoqi)
on 2007-04-29 03:43
Oh,yeah,I am successful!
I copy code from
http://www.rubyinside.com/how-to-create-a-ruby-ext...
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!
This topic is locked and can not be replied to.