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

  • SEARCH
  • Home
  • 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 8647265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:01:17+00:00 2026-06-12T13:01:17+00:00

Consider the program: #include <gc/gc.h> int main() { void* p = GC_MALLOC(15); } Under

  • 0

Consider the program:

#include <gc/gc.h>
int main() {
  void* p = GC_MALLOC(15);
}

Under Ubuntu 10.04 LTS this compiles (gcc -lgc test.c). Under 12.04 LTS:

/tmp/cc7GcTfU.o: In function `main':
main.c:(.text+0xe): undefined reference to `GC_malloc'
collect2: ld returned 1 exit status

It looks like between 10.04 and 12.04 they’ve changed the library not to compile in malloc replacements. Or that’s what I think this description of the libgc1c2 package says:

[...] However, it does not work as a drop-in malloc(3) replacement.

Is there a simple way to get around this? (Say, something simpler than recompiling libgc manually…)

  • 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-12T13:01:18+00:00Added an answer on June 12, 2026 at 1:01 pm

    To answer my own question: actually, the Boehm GC library still works the same way as it used to in 12.04. The problem is that GCC doesn’t! GCC has started to default to --as-needed, and it drops -lgc completely if it is at the beginning of the line. This is a very major change!!

    Solution is to move -lgc to the end:

    gcc test.c -lgc
    

    Or add:

    gcc -Wl,--as-needed -lgc test.c
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's consider this simple test program: #include <stdio.h> #include <string.h> int main(int argc, char
Consider the following program: #include <stdio.h> int main(void) { return 0; } When i
Consider this program: #include <map> #include <vector> typedef std::vector<int> IntVector; typedef std::map<IntVector,double> Map; void
Consider this program: #include <stdio.h> int main() { printf(%s\n, __FILE__); return 0; } Depending
Consider this little program: #include <stdio.h> int main() { char c = 0xFF; printf(%d\n,
Consider the following program: #include <iostream> #include boost/filesystem.hpp int main() { boost::filesystem::directory_entry d(test.txt); boost::filesystem::directory_entry
Consider this pointless program: /* main.c */ #include <stdlib.h> #include <unistd.h> int main(int argc,
Consider following program: static void Main (string[] args) { int i; uint ui; i
Consider this program int main() { float f = 11.22; double d = 44.55;
Consider this demo program: #include <stdio.h> class Base { public: virtual int f(int) =0;

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.