Thread: How to build multiple C files in VS code

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2019
    Posts
    97

    How to build multiple C files in VS code

    Hi guys,

    I try to compile a program with a main.c, file.c and file.h files
    The file.c and file.h are in another directory than the main.c
    I included the file.h in both main.c and file.c

    How to build multiple C files in VS code-screenshot_1-png

    How to build multiple C files in VS code-screenshot_2-png

    When I compile the program I get the the undefined reference error of myName(); that is declared in file.h and defined in file.c

    How to build multiple C files in VS code-screenshot_4-jpg

    I followed the suggestion in VS Code documentation to edit the tasks.json but it didn't work. I tried both the .cpp and c extension in the tasks.json. Now the file is like this:

    How to build multiple C files in VS code-screenshot_5-png

    If I build the files from the terminal gcc main.c Library/file.c it works fine

    I do not know what else I am missing. Any suggestion?
    Attached Images Attached Images How to build multiple C files in VS code-screenshot_3-png 
    Last edited by Nikosant03; 04-20-2023 at 09:34 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about C++ Splitting your Code into Multiple Files
    By roroprogram in forum C++ Programming
    Replies: 2
    Last Post: 02-16-2021, 03:23 PM
  2. Separating out code into multiple files
    By Richardcavell in forum C Programming
    Replies: 2
    Last Post: 04-24-2011, 05:13 PM
  3. Breaking up source code into multiple files
    By mherald81 in forum C Programming
    Replies: 9
    Last Post: 10-15-2010, 04:55 PM
  4. Replies: 13
    Last Post: 08-12-2010, 01:58 PM
  5. Splitting Code Into Multiple Files
    By pobri19 in forum C++ Programming
    Replies: 3
    Last Post: 09-15-2008, 04:21 AM

Tags for this Thread