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

The Archive Base Latest Questions

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

I have two files: osm.h and osm.cpp I tried to create static lib from

  • 0

I have two files: osm.h and osm.cpp

I tried to create static lib from them, called “libosm.a” with Makefile.

my cpp and h file work( I compiled them without Makefile), but my Makefile doesn’t work. This is the Makefile:

CC = g++
RANLIB = ranlib

LIBSRC = osm.cpp
LIBOBJ=$(LIBSRC:.cpp=.o)

CFLAGS = -Wall -g -O0
LOADLIBES = -L./

OSMLIB = libosm.a
TARGETS = $(OSMLIB)

all: $(TARGETS)

osm.o: osm.cpp osm.h
    $(CC) -c osm.cpp -o osm.o

$(TARGETS): $(LIBOBJ)
    ar rcs $(OSMLIB) osm.o
    ranlib $(OSMLIB)

clean:
    rm osm.o $(TARGETS) $(OSMLIB) $(LIBOBJ)

depend:
    makedepend -- $(CFLAGS) -- $(SRC) $(LIBSRC)

and this is part of the error I’m getting:

osm.o: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12

can anyone 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-05-31T03:48:26+00:00Added an answer on May 31, 2026 at 3:48 am

    I believe a make file as simple as this one will do the job

    LIBSRC = osm.cpp
    OSMLIB = libosm.a
    
    CFLAGS = -Wall -g -O0
    LOADLIBES = -L./
    
    $(OSMLIB): $(LIBSRC)
    

    just with the built-in rules of GNU make. And you really don’t want to set CC to g++ at all. If then to gcc which will pick the proper backend for you.

    Note: to see the built-in rules of your make, use this:

    make -pn -f /dev/null
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have two files:(localhost/template/) index.php template.php each time when i create an article(an article
I have two files A - nodes_to_delete and B - nodes_to_keep . Each file
Say I have two files where there is one number per line File 1
I have two files. I want to create pdf with these two files. does
I have two files Sample.cpp and Main_file.cpp. Sample.cpp has only one namespace n1 which
I have two files: index.php /lib/user.php Index contains the form: <div class=<? echo $msgclass;
i have two files one called stats.js one called storage.html in stats.js in contains
I have two files which are called version1 version2 Version1 has my own changes,
I have two files File 1 contains 3 fields File 2 contains 4 fields
I have two files once is named as test.cpp and another as ani.cpp. test.cpp

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.