Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

pb ld et gcc

1 réponse
Avatar
unbewust
j'ai un :

UnixUtils.h
qui d=E9clare une tripot=E9e de fonctions
un :
UnixUtils.c
qui les impl=E9mentes **TOUTES**

ensuite un UnixUtils_Test.c dans le cas il n'y a qu'un main, ce
fichier fait bien s=FBr un include de "ext/UnixUtils.c"


=E0 la compil j'ai les erreurs suivantes :
%> ./compil
.=2E/ext/UnixUtils.c: In function get_dirname:
.=2E/ext/UnixUtils.c:215: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.c:217: warning: return discards qualifiers from
pointer target type

~/work/C/rmovefile/test%> ./UnixUtils_test ./Users/yt/bin/../work/./
C////
path =3D ///Users/yt/bin/../work/C//// -o-> /Users/yt/work/C =3D
normalized path
path =3D Users/yt/bin/../work/C//// -o-> Users/yt/work/C =3D normalized
path
path =3D ./Users/yt/bin/../work/C//// -o-> Users/yt/work/C =3D normalized
path
path =3D ../Users/yt/bin/../work/C//// -o-> ../Users/yt/work/C =3D
normalized path
path =3D ./a_script -o-> ./a_script =3D normalized path
~/work/C/rmovefile/test%> ./
compil
.=2E/ext/UnixUtils.c: In function get_dirname:
.=2E/ext/UnixUtils.c:215: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.c:217: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.h:13: warning: unixPathExists used but never defined
/usr/bin/ld: Undefined symbols:
_unixPathExists
collect2: ld returned 1 exit status

~/work/C/rmovefile/test%> ./compil
.=2E/ext/UnixUtils.c: In function get_dirname:
.=2E/ext/UnixUtils.c:207: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.c:209: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.h:13: warning: unixPathExists used but never defined
/usr/bin/ld: Undefined symbols:
_unixPathExists
collect2: ld returned 1 exit status

~/work/C/rmovefile/test%> ./compil
.=2E/ext/UnixUtils.c: In function get_dirname:
.=2E/ext/UnixUtils.c:207: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.c:209: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.h:13: warning: unixPathExists used but never defined
/usr/bin/ld: Undefined symbols:
_unixPathExists
collect2: ld returned 1 exit status

~/work/C/rmovefile/test%> ./compil
.=2E/ext/UnixUtils.c: In function get_dirname:
.=2E/ext/UnixUtils.c:207: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.c:209: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.h:13: warning: unixPathExists used but never defined
/usr/bin/ld: Undefined symbols:
_unixPathExists
collect2: ld returned 1 exit status

~/work/C/rmovefile/test%> ./compil
.=2E/ext/UnixUtils.c: In function get_dirname:
.=2E/ext/UnixUtils.c:207: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.c:209: warning: return discards qualifiers from
pointer target type

~/work/C/rmovefile/test%> ./UnixUtils_test ./Users/yt/bin/../work/./
C////
Path normalization:
path =3D ///Users/yt/bin/../work/C//// -o-> /Users/yt/work/C =3D
normalized path
path =3D Users/yt/bin/../work/C//// -o-> Users/yt/work/C =3D normalized
path
path =3D ./Users/yt/bin/../work/C//// -o-> Users/yt/work/C =3D normalized
path
path =3D ../Users/yt/bin/../work/C//// -o-> ../Users/yt/work/C =3D
normalized path
path =3D ./a_script -o-> ./a_script =3D normalized path

Path exists?:
~/work/C/rmovefile/test%> ./
compil
.=2E/ext/UnixUtils.c: In function get_dirname:
.=2E/ext/UnixUtils.c:207: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.c:209: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.h:13: warning: unixPathExists used but never defined
/usr/bin/ld: Undefined symbols:
_unixPathExists
collect2: ld returned 1 exit status

~/work/C/rmovefile/test%> ./compil
.=2E/ext/UnixUtils.c: In function get_dirname:
.=2E/ext/UnixUtils.c:207: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.c:209: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.h:13: warning: unixPathExists used but never defined
.=2E/ext/UnixUtils.h:14: warning: isUnixRegFile used but never defined
/usr/bin/ld: Undefined symbols:
_isUnixRegFile
_unixPathExists
collect2: ld returned 1 exit status

~/work/C/rmovefile/test%> ./compil
.=2E/ext/UnixUtils.c: In function get_dirname:
.=2E/ext/UnixUtils.c:207: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.c:209: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.h:13: warning: unixPathExists used but never defined
.=2E/ext/UnixUtils.h:14: warning: isUnixRegFile used but never defined
.=2E/ext/UnixUtils.h:15: warning: isUnixDirectory used but never defined
/usr/bin/ld: Undefined symbols:
_isUnixDirectory
_isUnixRegFile
_path_basename
_path_dirname
_unixPathExists
collect2: ld returned 1 exit status

~/work/C/rmovefile/test%> ./compil > ~/Desktop/compil.txt
.=2E/ext/UnixUtils.c: In function get_dirname:
.=2E/ext/UnixUtils.c:207: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.c:209: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.h:13: warning: unixPathExists used but never defined
.=2E/ext/UnixUtils.h:14: warning: isUnixRegFile used but never defined
.=2E/ext/UnixUtils.h:15: warning: isUnixDirectory used but never defined
/usr/bin/ld: Undefined symbols:
_isUnixDirectory
_isUnixRegFile
_path_basename
_path_dirname
_unixPathExists
collect2: ld returned 1 exit status
~/work/C/rmovefile/test%> ./compil 2>&1 ~/Desktop/compil.txt
.=2E/ext/UnixUtils.c: In function get_dirname:
.=2E/ext/UnixUtils.c:207: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.c:209: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.h:13: warning: unixPathExists used but never defined
.=2E/ext/UnixUtils.h:14: warning: isUnixRegFile used but never defined
.=2E/ext/UnixUtils.h:15: warning: isUnixDirectory used but never defined
/usr/bin/ld: Undefined symbols:
_isUnixDirectory
_isUnixRegFile
_path_basename
_path_dirname
_unixPathExists
collect2: ld returned 1 exit status

~/work/C/rmovefile/test%> ./compil
.=2E/ext/UnixUtils.c: In function get_dirname:
.=2E/ext/UnixUtils.c:207: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.c:209: warning: return discards qualifiers from
pointer target type
.=2E/ext/UnixUtils.h:13: warning: unixPathExists used but never defined
.=2E/ext/UnixUtils.h:14: warning: isUnixRegFile used but never defined
.=2E/ext/UnixUtils.h:15: warning: C used but never defined
/usr/bin/ld: Undefined symbols:
_isUnixDirectory
_isUnixRegFile
_path_basename
_path_dirname
_unixPathExists
collect2: ld returned 1 exit status


pourtant unixPathExists, isUnixRegFile, isUnixRegFile et path_basename
sont tous bien d=E9finis, de la m=EAme mani=E8re dans le .h et le .c
correspondant...

alors je pense que c'est ma commande gcc qui n'est pas bonne , la
voici :
#! /usr/bin/env zsh

echo `gcc -o UnixUtils_test -framework Foundation ../ext/UnixUtils.c
UnixUtils_test.c`

exit 0

ma hi=E9rarchie de rep :

ext/
UnixUtils.c
UnixUtils.h
test
UnixUtils_test.c

ci qq'un a des lumi=E8res...

1 réponse

Avatar
Vincent Lefevre
Dans l'article ,
unbewust écrit:

j'ai un :

UnixUtils.h
qui déclare une tripotée de fonctions
un :
UnixUtils.c
qui les implémentes **TOUTES**

ensuite un UnixUtils_Test.c dans le cas il n'y a qu'un main, ce
fichier fait bien sûr un include de "ext/UnixUtils.c"


Tu fais un #include d'un fichier .c??? Ce n'est pas que c'est
interdit, mais ne t'étonne pas d'avoir des problèmes...

--
Vincent Lefèvre - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)