プログラミング

プログラミングに関するフォーラムです。VBAは除きます。
  • 解決済みのトピックにはコメントできません。
このトピックは解決済みです。
質問

 
(Windows 7 Home Premium : C)
gnuwin32のawkaがコケル
投稿日時: 17/02/22 10:44:23
投稿者: oyoyo_president

awkスクリプトをawkaでCに変換してコンパイルを試みています。
しかし、以下のようにリンクに失敗しています。アドバイスをお願いいたします。
 
C:\AWKA\test>awka -x -f Crossword_compiler_v22-4.awk
gcc: warning: '-mcpu=' is deprecated; use '-mtune=' or '-march=' instead
awka_out.c: In function 'MAIN':
awka_out.c:413:5: warning: label 'nextrec' defined but not used [-Wunused-label]
 
     nextrec:;
     ^
awka_out.c:395:10: warning: unused variable '_curfile' [-Wunused-variable]
   int i, _curfile;
          ^
awka_out.c:395:7: warning: variable 'i' set but not used [-Wunused-but-set-varia
ble]
   int i, _curfile;
       ^
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(init.o):init.c:(.bss+0x
c): multiple definition of `_argv'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../crt2.o:(.bss+0x0): first defined
here
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(builtin.o):builtin.c:(.
text+0x3c0b): undefined reference to `fork'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(error.o):error.c:(.text
+0x2fb): undefined reference to `sigaction'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(error.o):error.c:(.text
+0x320): undefined reference to `sigaction'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x10e
): undefined reference to `gethostbyname@4'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x189
): undefined reference to `htonl@4'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x19c
): undefined reference to `htonl@4'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x1b3
): undefined reference to `htons@4'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x1cb
): undefined reference to `htons@4'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x1eb
): undefined reference to `bind@12'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x231
): undefined reference to `connect@12'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x29d
): undefined reference to `geteuid'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x2f6
): undefined reference to `recvfrom@24'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x332
): undefined reference to `connect@12'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x357
): undefined reference to `listen@8'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x376
): undefined reference to `accept@12'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x3d8
): undefined reference to `socket@12'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x452
): undefined reference to `socket@12'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x47f
): undefined reference to `setsockopt@20'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x4c2
): undefined reference to `setsockopt@20'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x7be
): undefined reference to `fstat64'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x7ec
): undefined reference to `fcntl'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x84e
): undefined reference to `getservbyname@8'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x861
): undefined reference to `ntohs@4'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x8bc
): undefined reference to `getservbyname@8'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x8cf
): undefined reference to `ntohs@4'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0xb1a
): undefined reference to `fcntl'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0xb48
): undefined reference to `pipe'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0xb5a
): undefined reference to `pipe'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0xb67
): undefined reference to `fork'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0xbad
): undefined reference to `fcntl'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0xbc9
): undefined reference to `fcntl'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x294
f): undefined reference to `wait'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x29d
1): undefined reference to `wait'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(io.o):io.c:(.text+0x2a5
2): undefined reference to `fstat64'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(regex.o):regex.c:(.text
+0x4133): undefined reference to `bcopy'
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libawka.a(regex.o):regex.c:(.text
+0x4162): undefined reference to `bcopy'
collect2.exe: error: ld returned 1 exit status
Awka error: compile failed.
 

投稿日時: 17/03/01 09:49:49
投稿者: oyoyo_president

自己レスです。
cygwinにしたら解決しました。
具体的には、cygwinのgccでawkaを再コンパイルし、インストール。
だだし、awka本体のコンパイルではawka_res.oの定義無し問題でコケるので、本体はネットのバイナリを使い、それ以外のライブラリ等は再コンパイルしたものをインストールしました。
また、コンパイルは以下のシェルスクリプトで実行し、awkaよるC言語への変換ステップと、コンパイルを分けて判りやすくしました。
 
#!/bin/bash
awka -f $1".awk" >$1".c"
gcc -c $1".c" -I/usr/local/include -O2 -o $1".o"
gcc $1".o" -L/usr/local/lib -lawka -lm -O2 -o $1
rm *.c *.o
 
解決ということで閉じます。