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 6671327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:22:31+00:00 2026-05-26T03:22:31+00:00

What causes could there be, that gcc does not link to math.h even though

  • 0

What causes could there be, that gcc does not link to math.h even though I set the flag -lm?

me@mycomputer$ g++ template_gold.cpp -o template_gold -lm
template_gold.cpp: In function ‘void computeGold(valpoint*, centroid*, int)’:
template_gold.cpp:68: error: ‘max’ was not declared in this scope
template_gold.cpp:70: error: ‘abs’ was not declared in this scope

I am sorry, if this is a dupe, but searching the googles and SO I found only post suggesting to set the -lm.

Offending Code

#include <math.h>
#include "kmeans.h"
extern "C" 
void computeGold( valpoint* h_idata, centroid* h_centroids, int numClusters);
...
for (long valindex = 0; valindex<1024*1024; valindex++)
    {
        minDistance = 0xFFFFFFFF;
        for (k = 0; k<numClusters; k++)
            if (max((long)(h_idata[valindex].value - h_centroids[k].value))<minDistance)
            {
                minDistance = abs((long)(h_idata[valindex].value - h_centroids[k].value));
                myCentroid = k;
            }

        h_idata[valindex].centroid = h_centroids[myCentroid].value;

    }
}
  • 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-05-26T03:22:32+00:00Added an answer on May 26, 2026 at 3:22 am

    You probably forgot to use std::max, or you forgot adding using namespace std. Try

    void void computeGold(valpoint* ..., centroid* ..., int ...)
    {
        using namespace std; /* or using std::max etc. */
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not sure what I could be doing wrong that causes info level
What could be the possible causes for the following exception? System.PlatformNotSupportedException: 'ResourcePool' is not
Sys.Webforms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for
I have a weird condition that only appears on gcc -O0 -g output, not
Recently I came across a gcc extension that I have found rather useful: __attribute__(cleanup)
I've searched a lot but could not solve this problem. I am generating PDF
There's a method in a library out of my control that uses a block
Is there a plugin out there that will take an image that is uploaded
When analysing Oracle tkprof trace files I have noticed that there is sometimes a
I have a call to TraceSource.TraceEvent() that is sometimes not writing to the Azure

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.