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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:53:04+00:00 2026-06-08T20:53:04+00:00

I have added another rule to a Makefile to attempt to build a C

  • 0

I have added another rule to a Makefile to attempt to build a C shared library that uses SWIG to wrap the functions for Java using JNI

The additional rule looks like this (basically lifted from one of the SWIG java examples)

java: $(program_C_SRCS)
    $(SWIG) -java $(SWIGOPT) $(INTERFACEPATH)
    $(CC) -c $(CFLAGS) $(JAVACFLAGS) $(program_C_SRCS) $(ISRCS) $(CPPFLAGS) $(JAVA_INCLUDE)
    $(JAVALDSHARED) $(CFLAGS) $(program_C_OBJS) $(IOBJS) $(JAVA_DLNK) $(LDFLAGS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO)
    javac *.java

problem I have is that my VPATH doesn’t seem to work with the *.c files anymore

I noticed that this rule causes all the .c files to compiled as one call to gcc rather than a separate call to gcc for the compilation of each .o file

my previous rules for compilation without any JNI stuff look like this:

.PHONY: all clean

all: $(program_DEBUG_NAME) $(program_RELEASE_NAME)

# original rule to build library in src dir (no longer inc. in all)
$(program_NAME): $(program_C_OBJS)
    $(LINK.c) -shared -Wl,-soname,$@ $^ -o $@

# new rules to build debug/release libraries and place them in relevant build
# dirs
$(program_DEBUG_NAME): $(DEBUG_OBJS)
    $(DEBUG_LINK.c) -shared -Wl,-soname,$@ $^ -o $(BUILD_DIR)/debug/$@

$(program_RELEASE_NAME): $(RELEASE_OBJS)
    $(RELEASE_LINK.c) -shared -Wl,-soname,$@ $^ -o $(BUILD_DIR)/release/$@

# rule to build object files (replaces implicit rule)
$(BUILD_DIR)/debug/%.o: %.c
    $(DEBUG_LINK.c) $< -c -o $@

$(BUILD_DIR)/release/%.o: %.c
    $(RELEASE_LINK.c) $< -c -o $@

and these work with VPATH no problem

my VPATH statement looks like this:

VPATH = ../../pulse_IO/src ../../../g2/src
  • 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-08T20:53:06+00:00Added an answer on June 8, 2026 at 8:53 pm

    Look at your rule:

    java: $(program_C_SRCS)
        ...
        $(CC) -c $(CFLAGS) $(JAVACFLAGS) $(program_C_SRCS) ...
        ...
    

    Suppose program_C_SRCS is foo.c, and the path is somewhere/foo.c. Without VPATH, this rule doesn’t run at all because Make can’t find foo.c. With VPATH, Make finds it, and knows that the real prereq is somewhere/foo.c. But you have $(program_C_SRCS) in your rule:

    java: somewhere/foo.c
        ...
        $(CC) -c $(CFLAGS) $(JAVACFLAGS) foo.c ...
        ...
    

    This fails because there is no foo.c (locally).

    Try this:

    java: $(program_C_SRCS)
        ...
        $(CC) -c $(CFLAGS) $(JAVACFLAGS) $^ ...
        ...
    

    (The use of automatic variables like $^ is the reason your previous rules worked.)

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

Sidebar

Related Questions

I have created a cube that worked fine when deploying. After a added another
In my project, i have added another project as a library, Their are some
I'm programming an app that will have a free version. I have added another
I have added a navigation controller inside a viewcontroller thats inside another navigation controller...
I have Eclipse 3.4.2 installed on Windows with subclipse. Another developer added an SVN
I have one main project and another project which is added as a subprojects.
I have a User Control added to a Canvas. In another area of the
I need to have a new view(w/ ViewController) added over the top of another.
I have a tablelayout panel with multiple columns. I have added another 2 tablelayout
Using IIS 7, I have an existing website, example.com, and I have added another

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.