0

I am a freshman that attends a CS college. I am learning C and we have to use some external libraries . While no problems apppear when I include those libraries,when im using a library specific syntax(for example GetInteger) vs code outputs: " undefined reference to GetInteger"

Here is a simple example:

#include <stdio.h>
#include "simpio.h"
#include "genlib.h"
#include <stdlib.h>

int main()
{
   int age;
   printf("Whats your age?\n");
   
   age=GetInteger();
   printf("Your age is %d",age);
   return 0;
}

Those are my c_ccp_properties.json:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**","C:\\MinGW\\include","C:\\MinGW\\lib","C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:\\MinGW\\bin\\gcc.exe",
            "cStandard": "gnu11",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "gcc-x86"
        }
    ],
    "version": 4
} 

My launch.sjon:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "gcc.exe - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            
            "args":["-g", "-o", "out.exe", "main.cpp", "test.c"],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "\\usr\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: gcc.exe build active file"
        }
    ]
}

and my tasks.json:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "g++ build active file",
            "command": "/usr/bin/g++",
            "args": [],
            "options": {
                "cwd": "/usr/bin"
            }
        }]
}
sLorKinG
  • 1
  • 1
  • Did you link your library? – no more sigsegv Oct 22 '20 at 12:08
  • 1
    Where is your library mentioned in any of the files you have posted? – n. m. could be an AI Oct 22 '20 at 12:18
  • You need to include the library paths in your project. And also link with the libraries (if they are not include only libraries (i.e.: they get compiled with your project and there are not any .dll/.lib/.so). – fern17 Oct 22 '20 at 12:20
  • how do I link my libraries? I am sorry im very new to this. What info do you want me to provide. I ll try my best – sLorKinG Oct 22 '20 at 12:21
  • Your school or instructor should be giving you basic information about using the build tools, including instructions on how to tell the build system to include specific libraries when linking. – Eric Postpischil Oct 22 '20 at 12:23
  • 1
    My school is using codeblocks but for some reason it is bugged so my instructor told me to go to visual studio code – sLorKinG Oct 22 '20 at 12:38
  • Your bug is in your tasks.json. Related: [https://stackoverflow.com/questions/52910102/vscode-c-task-json-include-path-and-libraries](https://stackoverflow.com/questions/52910102/vscode-c-task-json-include-path-and-libraries) – drescherjm Oct 22 '20 at 13:26
  • please read [ask] and provide a [mcve] – specializt Oct 22 '20 at 13:39
  • This looks quite weird to me: `"miDebuggerPath": "\\usr\\bin\\gdb.exe",` it's a mix of unix and windows.. – drescherjm Oct 22 '20 at 13:45

0 Answers0