Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7953237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:06:10+00:00 2026-06-04T03:06:10+00:00

I keep coming across this common error then compiling my program. I’ve already tried

  • 0

I keep coming across this common error then compiling my program. I’ve already tried many of the suggestions on the internet but none have worked so far. I’ve tried compiling my code using g++ via CMD and Code::Blocks, but both come up with the same error:

C:\Users\Damian\Desktop\test program.cpp|17|undefined reference to `level1::segout(int, double, double)'

I’ve tried compiling in CMD using all the cpp files:

g++ "main program.cpp" "level1.cpp" -o "test.exe"

Here is my code below… maybe I am missing something obvious. It’s been a while since I did C/C++ coding.

main program.cpp

#define _USE_MATH_DEFINES

#include <iostream>
#include <C:\Users\Damian\Desktop\level1.h>
#include <string>
#include <math.h>
using namespace std;

int main()
{
    double pitch = 0;
    double yaw = 0;
    cout << "Low-Level Test Program\nPlease enter the pitch value (in degrees):\n";
    cin >> pitch;
    cout << "Please enter the yaw value (in degrees):\n";
    cin >> yaw;
    level1::segout(0, pitch * (M_PI/180), yaw * (M_PI/180));
    return 0;
}

level1.h

//all dimensions in MM, all angles in RADIANS

#pragma once

class level1 {
        static const double LENGTH_NEUTRAL, ANGLE_MAX, RADIUS, WIRE_RADIUS, ENCODER_RES;
        double L1, L2, L3;
    public:
        static void segout(int, double, double);
};

level1.cpp

#define _USE_MATH_DEFINES

#include <iostream>
#include <math.h>
#include <stdlib.h>
//#include <level0.h> --not implemented yet
using namespace std;

const double LENGTH_NEUTRAL = 30;
const double ANGLE_MAX = M_PI/4;
const double RADIUS = 16;
const double WIRE_RADIUS = 0.1;
const double ENCODER_RES = (2*M_PI)/64;

void segout(int Seg, double P, double Y)
{
    //work area check
    if (sqrt(pow(P, 2) + pow(Y, 2)) <= LENGTH_NEUTRAL + ANGLE_MAX)
    {
        cout << "ERROR (0001): Specified coordinates are outside work area.\n";
        return;
    }

    //conversion

    //stage 1
    double L1 = LENGTH_NEUTRAL * (1 - ((sqrt(pow(P, 2) + pow(Y, 2)))/LENGTH_NEUTRAL) * RADIUS * sin((M_PI/2)+atan2(P, Y)));

    double L2 = LENGTH_NEUTRAL * (1 + ((sqrt(pow(P, 2) + pow(Y, 2)))/LENGTH_NEUTRAL) * RADIUS * sin((5*M_PI/6)+atan2(P, Y)));

    double L3 = LENGTH_NEUTRAL * (1 + ((sqrt(pow(P, 2) + pow(Y, 2)))/LENGTH_NEUTRAL) * RADIUS * cos((2*M_PI/3)+atan2(P, Y)));

    //stage 2
    L1 = labs((sqrt((L1 * sqrt(4 * pow(LENGTH_NEUTRAL, 2)+ pow(L1, 2)))/(pow(WIRE_RADIUS, 2)) - (pow(L1, 2))/(pow(WIRE_RADIUS, 2)))/sqrt(2)) / ENCODER_RES);

    L2 = labs((sqrt((L2 * sqrt(4 * pow(LENGTH_NEUTRAL, 2)+ pow(L2, 2)))/(pow(WIRE_RADIUS, 2)) - (pow(L2, 2))/(pow(WIRE_RADIUS, 2)))/sqrt(2)) / ENCODER_RES);

    L3 = labs((sqrt((L3 * sqrt(4 * pow(LENGTH_NEUTRAL, 2)+ pow(L3, 2)))/(pow(WIRE_RADIUS, 2)) - (pow(L3, 2))/(pow(WIRE_RADIUS, 2)))/sqrt(2)) / ENCODER_RES);

    //output
    //temp output for debugging
    cout << "-------\nResults:\n";
    cout << "L1: " << L1 << "\n";
    cout << "L2: " << L2 << "\n";
    cout << "L3: " << L3 << "\n";
}

Here’s an inexhaustive list of the things I’ve tried so far:

  • Changing level1 from a static class to a normal class (so I have to create an object for it to work)
  • Including the desktop in the search paths
  • Compiling level1 to an object first and then compiling it with the main program.
  • Turning on Linker AND/OR Compile for the header file in Code::Blocks
  • Putting a level1.h #include header in level1.cpp

There’s probably a few more, but’s it’s late and my memory’s going… thanks very much in advance for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:06:12+00:00Added an answer on June 4, 2026 at 3:06 am

    Your problem is that

    void segout(int Seg, double P, double Y)
    

    is not the same as

    void level1::segout(int Seg, double P, double Y)
    

    So you are declaring one function and defining another. That’s why the linker can’t find the definition for your function. When working with member functions, be they static or non-static, you need to scope them within their class.

    Also, bracket <includes> are for system libraries. Anything else should use quoted “includes”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep coming across the use of this word and I never understand its
I'm learning javascript. Poked around this excellent site to gather intel. Keep coming across
I keep coming across this problem, where i want to insert an IF statement
This is an issue I seem to keep coming across. If for example I
Suggestions on resolving this? I keep coming up with missing line numbers when consulting
I've been studying class inheritance recently and I keep coming across this specific piece
So, one problem pattern that I keep coming across and don't have a good
I've been searching for this for a while and keep coming up short. However
Keep getting this error after inserting a subdatasheet into a query and trying to
I keep coming across techniques like the code below where i need to filter

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.