리눅스 이클립스 오류 해결방안좀 알려주세요..

gyung go의 이미지

22:37:24 **** Build of configuration Debug for project Hello ****
make all
Building file: ../main.c
Invoking: GCC C Compiler
gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.o" -o "main.o" "../main.c"
Finished building: ../main.c

Building target: Hello
Invoking: GCC C Linker
gcc -o "Hello" ./main.o
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
makefile:29: recipe for target 'Hello' failed
collect2: error: ld returned 1 exit status
make: *** [Hello] Error 1
"make all" terminated with exit code 2. Build might be incomplete.

22:37:25 Build Failed. 3 errors, 0 warnings. (took 346ms)

처음에 이클립스를 실행해서 hello world 출력 하려는데
이런 오류가 뜹니다 (사진은 코드 + 오류 내용)

problems

Description Resource Path Location Type
make: *** [Hello] Error 1 Hello C/C++ Problem

Description Resource Path Location Type
recipe for target 'Hello' failed makefile /Hello/Debug line 29 C/C++ Problem

Description Resource Path Location Type
undefined reference to `main' Hello C/C++ Problem

이렇게 3가지 오류가 뜨는데요 (파일 이름은 Hello)

저 오류가 안뜰때는 콘솔에서

22:47:05 **** Incremental Build of configuration Debug for project Hello ****
make all
Building file: ../main.c
Invoking: GCC C Compiler
gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.o" -o "main.o" "../main.c"
Finished building: ../main.c

Building target: Hello
Invoking: GCC C Linker
gcc -o "Hello" ./main.o
Finished building target: Hello

22:47:05 Build Finished. 0 errors, 0 warnings. (took 296ms)

이렇게만 뜨고 결과물은 출력이 안나옵니다

그러면 그다음 launch 누르면

22:48:47 **** Incremental Build of configuration Debug for project Hello ****
make all
make: 'all'을(를) 위해 할 일이 없습니다.

22:48:47 Build Finished. 0 errors, 0 warnings. (took 77ms)

이거 뜨면서 아무것도 안됩니다

버추얼박스에 리눅스 깔아서 하는데 계속 삭제하고 다시해봐도 반복입니다...

추가로 makefile 폴더 안 내용입니다
################################################################################
# Automatically-generated file. Do not edit!
################################################################################

-include ../makefile.init

RM := rm -rf

# All of the sources participating in the build are defined here
-include sources.mk
-include subdir.mk
-include objects.mk

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif

-include ../makefile.defs

# Add inputs and outputs from these tool invocations to the build variables

# All Target
all: Hello

# Tool invocations
Hello: $(OBJS) $(USER_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: GCC C Linker'
gcc -o "Hello" $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '

# Other Targets
clean:
-$(RM) $(EXECUTABLES)$(OBJS)$(C_DEPS) Hello
-@echo ' '

.PHONY: all clean dependents

-include ../makefile.targets

초보자라 처음부터 알려주세요 ㅠㅠ

File attachments: 
첨부파일 크기
Image icon 스크린샷, 2020-04-06 22-38-27.png176.88 KB
Stephen Kyoungwon Kim@Google의 이미지

.c 파일은 컴파일 되고 링킹은 안 된 것 같은데 main.c 소스 코드를 올려 보세요.

gyung go의 이미지

#include

int main()

{

printf("Hello World!");

return 0;
}

Stephen Kyoungwon Kim@Google의 이미지

code tag block을 이용하세요. 댓글이나 글 쓰시기 전에 회색으로 미리 쓰여져 있는 텍스트를 참고하세요.

소스 코드는 문제가 없는 것 같고 이클립스 설정 문젭니다. 배포판도 많고 버전도 많고 설치/설정하는 방법도 다양해서 주어진 정보만으론 뭐가 잘못 되었는지 모르겠네요.

swish95의 이미지

뭐 때문에 make 까지 거치도록 하신지는 모르겠지만
그냥 터미널로 하시는걸 추천 드립니다.

본인이 모르는 영역이 알아서 돌아가는건 결국 사고 터지면 더 미궁이니까요

------------------------------------------------------------
ProgrammingHolic

익명 사용자의 이미지

hello.c 로 저장합니다.

#include <stdio.h>
 
int main ()
{
  printf ("Hello World!\n");
  return 0;
}

아래 처럼 명령하면 hello 라는 실행 파일이 만들어집니다.

cc -o hello hello.c

위의 명령줄에서 cc 는 c compiler 의 약자이고, 그 약자가 일반적인 명령어입니다.
gcc 를 설치하셨다면 cc 하면 gcc 가 실행될거에요.
-o 라는 옵션은 output 을 지정해주는거에요.
-o Hello 라고 하면 Hello 라는 실행파일이 생성되고,
-o hello 라고 하면 hello 라는 실행파일이 생성됩니다.

우선 위 내용부터 숙지하시기 바랍니다. Makefile 이라는 것을 이해하는 것은 그 다음 순서입니다.
eclipse 같은 IDE 를 사용하면 위 명령을 자동화해줍니다. 그런데 기초가 없는 상태에서 eclipse 설정을 잘못하면 뭐가 문제인지 모르겠죠. IDE(Integrated Development Environment) 란 통합개발환경을 의미합니다.
단순히 한두번 하다 말 것이 아니라면 c 관련책을 보세요.

익명 사용자의 이미지

그리고 리눅스 터미널에서 hello 명령을 실행하려면, 경로가 지정되어 있기 않기 때문에
./hello 이렇게 명령해야 합니다. 무슨 말인지 하나도 이해 안 될거에요.
그냥 그런가부다 하고 넘어가세요. 나중에 시간되실 때 리눅스 책 하나 사서 보세요.
거기 다 나옵니다. 단편적으로 하나씩 인터넷에 질문하고 답변 기다라는 것보다
시간 소비가 더 적고 리눅스 책 1권, c 책 1권 이렇게 두권을 한두달 정도 완독하면 리눅스/c 기초는 습득할 수 있습니다.

익명 사용자의 이미지

그리고 흔히들, 초보 때 IDE(이클립스, vscode 등)를 사용하는게 도움이 된다고들 생각하시는데 저는 생각이 다릅니다. IDE 없으면 개발 못하는 사람들도 뙈 있는 것 같은데, 초보 때는 이클립스 없이 공부하십시오.
vi까지는 아니더라도 일반 텍스트 에디터로 hello.c 소스코드 작성하고, 터미널에서 cc 명령으로 hello 라는 실행 파일을 생성하는 것이 정석입니다. 그렇게 공부/개발하면서 파일 수가 늘어나면 그 때 Makefile 을 공부하여 make 로 컴파일/빌드를 자동화하시고, 소스코드 양이 1만줄 넘어가면 그 때부터 IDE 써도 늦지 않습니다.
기초도 없는 상태에서 IDE 를 사용하면 모래 위에 성을 짓는 것과 별반 다를게 없어서 뭔가 문제가 발생되거나 IDE 를 사용할 수 없는 환경에서 개발이라는 걸 하지도 못하는 어처구니 없는 불상사가 발생할 것입니다.

Stephen Kyoungwon Kim@Google의 이미지

위 익명사용자님 답글에 조금 보태자면 kldp에 짧고 이해하기 쉽고 나름 충실한 gcc와 make 매뉴얼이 있습니다.
http://doc.kldp.org/KoreanDoc/html/gcc_and_make/gcc_and_make.html

raymundo의 이미지

코드에 분명 main 함수가 있는데 정작 링킹 과정에서 없다고 나온다...

그리고 스크린샷 보면 탭 제목 부분에 main.c 왼쪽에 * 표시가 있다...

혹시 main.c 를 작성한 후 저장을 하지 않고 컴파일을 시켜서 그런 게 아닌가 싶습니다.

좋은 하루 되세요!

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.