# \[Bug:trunk\] cross-compiling ext/tk

**URL:** <https://www.ruby-forum.com/t/bug-trunk-cross-compiling-ext-tk/187950>\
**Category:** Development\
**Created:** [May 3, 2010, 7:18am UTC](https://www.ruby-forum.com/t/bug-trunk-cross-compiling-ext-tk/187950 "2010-05-03T07:18:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nobu](https://www.ruby-forum.com/u/nobu)\
**Post date:** [May 3, 2010, 7:18am UTC](https://www.ruby-forum.com/t/bug-trunk-cross-compiling-ext-tk/187950/1 "2010-05-03T07:18:55Z")

</div>

e$B$J$+$@$G$9!#e(B

e$B%/%m%9%3%s%Q%$%k$N$H$-$Ke(Bext/tk/extconf.rbe$B$,E,@Z$J%G%#%l%/%H%j$re(B  
e$BC5$7$F$$$^$;$s!#$^$?!"e(Bis\_win32?e$B$N$H$-$KF1$8%G%#%l%/%H%j$r!"M?$(e(B  
e$B$i$l$?%Q%9\<+BN$He(B\e$B$re(B/e$B$KCV49$7$?$b$N$H%I%i%$%V%l%?!\<$ND\>8e$Ne(B/e$B$rFse(B  
e$B=E$K$7$?$b$N$H$H!“3Fe(B3e$B2s$:$DC5$7$F$$$k$h$&$J$s$G$9$,!”$3$l$O$J$\<e(B  
e$B$G$7$g$&$+!#$H$/$K:G8e$N$b$N$O%I%i%$%V%l%?!\<$,$J$$\>l9g$Oe(BUNCe$B$K$J$Ce(B  
e$B$F$7$^$&$N$G0UL#$,JQ$o$C$F$7$^$&$H;W$$$^$9!#e(B

diff --git i/ext/tk/extconf.rb w/ext/tk/extconf.rb  
index 676c132…a8adac2 100644  
— i/ext/tk/extconf.rb  
+++ w/ext/tk/extconf.rb  
@@ -193,5 +193,6 @@ def get\_shlib\_path\_head  
end

- if is\_win32?

- if CROSS\_COMPILING
- elsif is\_win32?  
drive, drv\_regexp = win\_drive  
if TkLib\_Config[“ActiveTcl”]  
@@ -422,5 +423,6 @@ def get\_tclConfig\_dirs  
config\_dir = []

- if is\_win32?

- if CROSS\_COMPILING
- elsif is\_win32?  
drive, drv\_regexp = win\_drive  
if TkLib\_Config[“ActiveTcl”]  
@@ -559,5 +561,6 @@ def search\_tclConfig(\*paths) # libdir list or  
[tcl-libdir|file, tk-libdir|file]  
conf = nil

- (config\_dir | config\_dir).map{|dir|

- config\_dir.uniq!
- config\_dir.map{|dir|  
if dir.kind\_of? Array  
[dir[0].strip.chomp(’/’), dir[1].strip.chomp(’/’)]  
@@ -603,5 +606,5 @@ def search\_tclConfig(\*paths) # libdir list or  
[tcl-libdir|file, tk-libdir|file]  
# nativethread check  
if !TkLib\_Config[“ruby\_with\_thread”] && tclconf[‘TCL\_THREADS’] ==  
‘1’

- 

```
   puts "WARNIG: find #{tclpath.inspect}, but it WITH 

```

nativethread-support under ruby WITHOUT nativethread-support. So, ignore  
it."

- 

```
   puts "WARNING: found #{tclpath.inspect}, but it WITH 

```

nativethread-support under ruby WITHOUT nativethread-support. So, ignore  
it."  
TkLib\_Config[“tcltk-NG-path”] \<\< File.dirname(tclpath)  
next  
@@ -648,5 +651,5 @@ def search\_tclConfig(\*paths) # libdir list or  
[tcl-libdir|file, tk-libdir|file]

```
   unless tcllib_ok && tklib_ok

```

- 

```
   puts "WARNIG: find #{tclpath.inspect}, but cannot find valid 

```

Tcl/Tk libraries on the same directory. So, ignore it."

- 

```
   puts "WARNING: found #{tclpath.inspect}, but cannot find valid 

```

Tcl/Tk libraries on the same directory. So, ignore it."  
TkLib\_Config[“tcltk-NG-path”] \<\< File.dirname(tclpath)  
next  
@@ -788,17 +791,15 @@ def check\_shlib\_search\_path(paths)

path\_list = check\_NG\_path(path\_list)

- path\_list.map!{|path| path.strip}

- if is\_win32?

- if !CROSS\_COMPILING and is\_win32?
# exist-dir only
drive, drv\_regexp = win\_drive

- path\_list.each{|path|
- 

```
 path = path.strip;

```

- 

```
 #$LIBPATH |= [path] if File.directory?(path)

```

- 

```
 $LIBPATH |= [path.sub(%r|^(#{drv_regexp})?//|, '\1/')] unless 

```

Dir.glob(File.join(path, “\*.{a,so,dll,lib}”)).empty?

- }
- else
- 
# keep paths for searching dynamic libs
- path\_list.each{|path| $LIBPATH |= [path.strip] }

- path\_list.map!{|path| path.sub(%r|^(#{drv\_regexp})?//|, ‘\1/’)}
- path\_list.delete\_if{|path| Dir.glob(File.join(path,  
“\*.{a,so,dll,lib}”)).empty?}  
end
- 
- 
# keep paths for searching dynamic libs
- $LIBPATH |= path\_list  
end

@@ -842,5 +843,5 @@ def find\_tcl(tcllib, stubs, version, \*opt\_paths)  
File.join(RbConfig::CONFIG[‘prefix’], ‘lib’),  
“/usr/local/lib”, “/usr/pkg/lib”, “/usr/contrib/lib”, “/usr/lib”

- ].find\_all{|dir| File.directory?(dir)}

- ].find\_all{|dir| File.directory?(dir)} unless CROSS\_COMPILING

- if is\_win32?

- if !CROSS\_COMPILING and is\_win32?  
drive, drv\_regexp = win\_drive  
if TkLib\_Config[“ActiveTcl”]  
@@ -874,34 +875,22 @@ def find\_tcl(tcllib, stubs, version, \*opt\_paths)  
end

- env\_paths = []
- ENV[‘PATH’].split(File::PATH\_SEPARATOR).each{|dir|
- env\_paths \<\< File.expand\_path(File.join(dir, ‘…’, ‘lib’))
- env\_paths \<\< dir
- env\_paths \<\< File.expand\_path(File.join(dir, ‘…’))
- if is\_win32?
- 

```
 if dir.gsub!(/\\/, '/')

```

- 

```
   env_paths << File.expand_path(File.join(dir, '..', 'lib'))

```

- 

```
   env_paths << dir

```

- 

```
   env_paths << File.expand_path(File.join(dir, '..'))

```

- 

```
 end

```

- 

```
 if dir.sub!(%r|^(#{drv_regexp})?/([^/])|, '\1//\2')

```

- 

```
   env_paths << File.expand_path(File.join(dir, '..', 'lib'))

```

- 

```
   env_paths << dir

```

- 

```
   env_paths << File.expand_path(File.join(dir, '..'))

```

- 

```
 end

```

- unless CROSS\_COMPILING
- env\_paths = []
- ENV[‘PATH’].split(File::PATH\_SEPARATOR).each{|dir|
- 

```
 env_paths << File.expand_path(File.join(dir, '..', 'lib'))

```

- 

```
 env_paths << dir

```

- 

```
 env_paths << File.expand_path(File.join(dir, '..'))

```

- }
- 
- if File::ALT\_SEPARATOR
- 

```
 env_paths.map!{|dir| dir.tr(File::ALT_SEPARATOR, 

```

File::SEPARATOR)}  
end

- }

- if is\_win32?

- env\_paths = env\_paths.find\_all{|d|

- 

```
 not (Dir.glob(File.join(d, "*[Tt]cl*")) | 

```

Dir.glob(File.join(d.sub(%r|^(#{drv\_regexp})?/([^/])|, ‘\1//\2’),  
“_[Tt]cl_”))).empty?

- }
- else
- env\_paths = env\_paths.find\_all{|d|
- 

```
 not (Dir.glob(File.join(d, "*[Tt]cl*"))).empty?

```

- env\_paths.delete\_if{|d|
- 

```
 (Dir.glob(File.join(d, "*[Tt]cl*"))).empty?

```

}

- end

- default\_paths.concat env\_paths

- default\_paths.concat env\_paths

- end

- ].find\_all{|dir| File.directory?(dir)}

- ].find\_all{|dir| File.directory?(dir)} unless CROSS\_COMPILING

- if is\_win32?

- if !CROSS\_COMPILING and is\_win32?  
drive, drv\_regexp = win\_drive  
if TkLib\_Config[“ActiveTcl”]  
@@ -1042,34 +1031,22 @@ def find\_tk(tklib, stubs, version, \*opt\_paths)  
end

- env\_paths = []
- ENV[‘PATH’].split(File::PATH\_SEPARATOR).each{|dir|
- env\_paths \<\< File.expand\_path(File.join(dir, ‘…’, ‘lib’))
- env\_paths \<\< dir
- env\_paths \<\< File.expand\_path(File.join(dir, ‘…’))
- if is\_win32?
- 

```
 if dir.gsub!(/\\/, '/')

```

- 

```
   env_paths << File.expand_path(File.join(dir, '..', 'lib'))

```

- 

```
   env_paths << dir

```

- 

```
   env_paths << File.expand_path(File.join(dir, '..'))

```

- 

```
 end

```

- 

```
 if dir.sub!(%r|^(#{drv_regexp})?/([^/])|, '\1//\2')

```

- 

```
   env_paths << File.expand_path(File.join(dir, '..', 'lib'))

```

- 

```
   env_paths << dir

```

- 

```
   env_paths << File.expand_path(File.join(dir, '..'))

```

- 

```
 end

```

- unless CROSS\_COMPILING
- env\_paths = []
- ENV[‘PATH’].split(File::PATH\_SEPARATOR).each{|dir|
- 

```
 env_paths << File.expand_path(File.join(dir, '..', 'lib'))

```

- 

```
 env_paths << dir

```

- 

```
 env_paths << File.expand_path(File.join(dir, '..'))

```

- }
- 
- if File::ALT\_SEPARATOR
- 

```
 env_paths.map!{|dir| dir.tr(File::ALT_SEPARATOR, 

```

File::SEPARATOR)}  
end

- }

- if is\_win32?

- env\_paths = env\_paths.find\_all{|d|

- 

```
 not (Dir.glob(File.join(d, "*[Tt]k*")) | 

```

Dir.glob(File.join(d.sub(%r|^(#{drv\_regexp})?/([^/])|, ‘\1//\2’),  
“_[Tt]k_”))).empty?

- }
- else
- env\_paths = env\_paths.find\_all{|d|
- 

```
 not (Dir.glob(File.join(d, "*[Tt]k*"))).empty?

```

- env\_paths.delete\_if{|d|
- 

```
 (Dir.glob(File.join(d, "*[Tt]k*"))).empty?

```

}

- end

- default\_paths.concat env\_paths

- default\_paths.concat env\_paths

- end

- if is\_win32?

- if !CROSS\_COMPILING && is\_win32?  
drive, drv\_regexp = win\_drive  
if TkLib\_Config[“ActiveTcl”]  
@@ -1199,15 +1176,9 @@ def find\_tcltk\_header(tclver, tkver)  
base\_dir \<\< dir  
base\_dir \<\< File.expand\_path(File.join(dir, ‘…’))

- 

```
 if dir.gsub!(/\\/, '/')

```

- 

```
   base_dir << File.expand_path(File.join(dir, '..', 'include'))

```

- 

```
   base_dir << dir

```

- 

```
   base_dir << File.expand_path(File.join(dir, '..'))

```

- 

```
 end

```

- 

```
 if dir.sub!(%r|^(#{drv_regexp})?/([^/])|, '\1//\2')

```

- 

```
   base_dir << File.expand_path(File.join(dir, '..', 'include'))

```

- 

```
   base_dir << dir

```

- 

```
   base_dir << File.expand_path(File.join(dir, '..'))

```

- 

```
 end

```

}

- 
- if File::ALT\_SEPARATOR
- 

```
 base_dir.map!{|dir| dir.tr(File::ALT_SEPARATOR, File::SEPARATOR)}

```

- end  
end

---

<div class="post-metadata">

**Author:** ![nobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nobu](https://www.ruby-forum.com/u/nobu)\
**Post date:** [May 5, 2010, 12:17pm UTC](https://www.ruby-forum.com/t/bug-trunk-cross-compiling-ext-tk/187950/2 "2010-05-05T12:17:50Z")

</div>

e$B%A%1%C%He(B #3238 e$B$,99?7$5$l$^$7$?!#e(B (by Hidetoshi Nagai)

e$B%9%F!\<%?%9e(B Assignede$B$+$ie(BClosede$B$KJQ99e(B  
e$B?JD=e(B % 0e$B$+$ie(B100e$B$KJQ99e(B

This issue was solved with changeset r27627.  
Nobuyoshi, thank you for reporting this issue.  
Your contribution to Ruby is greatly appreciated.  
May Ruby be with you.

* * *

[http://redmine.ruby-lang.org/issues/show/3238](http://redmine.ruby-lang.org/issues/show/3238)
