Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile无法正常工作 #1

Open
wurui1994 opened this issue Nov 6, 2017 · 4 comments · May be fixed by #2
Open

Makefile无法正常工作 #1

wurui1994 opened this issue Nov 6, 2017 · 4 comments · May be fixed by #2

Comments

@wurui1994
Copy link

Manjaro上会报错:
[wurui@computer light2d]$ make
cc basic.c -o basic
/tmp/ccb1Fj9Q.o:在函数‘circleSDF’中:
basic.c:(.text+0x104e):对‘sqrtf’未定义的引用
/tmp/ccb1Fj9Q.o:在函数‘sample’中:
basic.c:(.text+0x1189):对‘sinf’未定义的引用
basic.c:(.text+0x119e):对‘cosf’未定义的引用
/tmp/ccb1Fj9Q.o:在函数‘main’中:
basic.c:(.text+0x1264):对‘fminf’未定义的引用
collect2: 错误:ld 返回 1
make: *** [<内置>:basic] 错误 1

必须要改成这样,才能正常工作:
TARGETS=basic csg
OUTPUTS=$(addsuffix .png, $(TARGETS))

all: $(TARGETS)
test: $(TARGETS) $(OUTPUTS)

%: %.c
gcc -lm -Wall -O3 -o $@ $&lt;

%.png: %
sh -c "time ./$<"

clean:
rm $(TARGETS) *.png

@leinlin
Copy link

leinlin commented Nov 10, 2017

用Unity 把算法 依葫芦画瓢的搞了一个下来,makefile文盲可以来试试看
https://github.com/ElPsyCongree/light2d_for_unity

@miloyip
Copy link
Owner

miloyip commented Nov 11, 2017

@wurui1994 感觉这是平台的问题。例子代码都只使用了 C99 标准库。

@kimci86
Copy link

kimci86 commented Nov 27, 2017

I had a similar issue because of a small mistake in the makefile : %.: %.c should be %: %.c (notice the dot). Then I had to add the -lm flag for gcc.

@micfan
Copy link

micfan commented Mar 27, 2019

gcc (GCC) 8.2.1 20181127 compile error, how to solve it?

gcc -Wall -O3 -o csg csg.c
/usr/bin/ld: /tmp/ccv6tJMs.o: in function `circleSDF':
csg.c:(.text+0xa1a): undefined reference to `sqrtf'
/usr/bin/ld: /tmp/ccv6tJMs.o: in function `scene':
csg.c:(.text+0xc03): undefined reference to `sqrtf'
/usr/bin/ld: csg.c:(.text+0xc30): undefined reference to `sqrtf'
/usr/bin/ld: /tmp/ccv6tJMs.o: in function `trace':
csg.c:(.text+0xd8b): undefined reference to `sqrtf'
/usr/bin/ld: csg.c:(.text+0xe2d): undefined reference to `sqrtf'
/usr/bin/ld: /tmp/ccv6tJMs.o: in function `sample':
csg.c:(.text+0xf0d): undefined reference to `sincosf'
/usr/bin/ld: csg.c:(.text+0x1053): undefined reference to `sqrtf'
/usr/bin/ld: csg.c:(.text+0x10a6): undefined reference to `sqrtf'
/usr/bin/ld: /tmp/ccv6tJMs.o: in function `main':
csg.c:(.text.startup+0x63): undefined reference to `fminf'
collect2: error: ld returned 1 exit status
make: *** [makefile:11: csg] Error 1

@micfan micfan linked a pull request Mar 27, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants