0

I've a problem compiling the following programm:

// hauptteil.c (main part)
#include "nebenfkt.h"
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    int x =10;
    int ergebnis=0;
    ergebnis =ver(x);
    printf("Doubled number: %d", ergebnis);
    return 0;
}
//nebenfkt.h
int ver(int x);
#include "nebenfkt.h"
#include <stdio.h>
#include <stdlib.h>


int ver(int x)
{
    int rueck;
    rueck= x*2;
    return rueck;
}

VSC gives me the feedback "* undefined reference to `ver' collect2.exe: error: ld returned 1 exit status*"

Solution

The problem occurred because I only used the command "gcc hauptteil.c -o function" Instead of "gcc hauptteil.c nebenfkt.c -o function"

4
  • 1
    There is nothing called ausgabe in this code. Commented Aug 30, 2022 at 14:44
  • Forgive me, it was from my second try ausgabe is the same as ver. I fixed the text Commented Aug 30, 2022 at 14:50
  • 1
    What command is used to compile the code? It needs to be passed both .c files. Commented Aug 30, 2022 at 14:51
  • @vukstudent: could you move the solution to the answer section? Self-answered questions are welcome here. Commented Sep 4, 2022 at 17:47

1 Answer 1

0

My mistake was discovered by Eugene Sh.

My mistake was that I only used the command "gcc hauptteil.c -o function" Instead of "gcc hauptteil.c nebenfkt.c -o function".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.