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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:07:59+00:00 2026-05-30T18:07:59+00:00

This is the error I get when running make clean all: rm -f mux-tool.o

  • 0

This is the error I get when running make clean all:

rm -f mux-tool.o mux-tool
g++ -ggdb -Wall -I ../include -c mux-tool.cpp
g++ -ggdb -Wall -I ../include -o mux-tool ../system/usermux/usermux.o mux-tool.o
mux-tool.o: In function `main':
/home/mdrc/beagle/user-space/mux-tools/mux-tool.cpp:35: undefined reference to `setmux(MuxConfig*)'
/home/mdrc/beagle/user-space/mux-tools/mux-tool.cpp:41: undefined reference to `getmux(MuxConfig*)'
collect2: ld returned 1 exit status
make: *** [mux-tool] Error 1

In user-space/include/system I have usermux.h as follows:

typedef struct {
    unsigned long address;
    unsigned char mode;
    unsigned char input_enable;
    unsigned char pullupdown_enable;
    unsigned char pullupdown_up;
} MuxConfig;

int setmux(MuxConfig* mux);
int getmux(MuxConfig* mux);

in user-space/system/usermux is usermux.c with:

#include <system/usermux.h>

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
#include <ctype.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/mman.h>

#define MAP_SIZE 4096UL
#define MAP_MASK (MAP_SIZE - 1)

int setmux(MuxConfig* mux) {
    int fd;
    void *map_base, *virt_addr; 
    unsigned short writeval;

    if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) {
        return -1;
    }

    map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, mux->address & ~MAP_MASK);

    if(map_base == (void *) -1) return -1;

    virt_addr = map_base + (mux->address & MAP_MASK);

                                writeval = mux->mode & 7;
    if (mux->input_enable)      writeval |= 1 << 8;
    if (mux->pullupdown_enable) writeval |= 1 << 3;
    if (mux->pullupdown_up)     writeval |= 1 << 4;

    *((unsigned short *) virt_addr) = writeval;

    if (close(fd)) return -1;

    return 0;
}

int getmux(MuxConfig* mux) {
    int fd;
    void *map_base, *virt_addr; 
    unsigned short readval;

    if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) {
        return -1;
    }

    map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, mux->address & ~MAP_MASK);

    if(map_base == (void *) -1) return -1;

    virt_addr = map_base + (mux->address & MAP_MASK);

    readval = *((unsigned short *) virt_addr);

    mux->mode               = readval &   0x7;
    mux->pullupdown_enable  = (readval &   0xF) != 0;
    mux->pullupdown_up      = (readval &  0x10) != 0;
    mux->input_enable       = (readval & 0x100) != 0;

    if (close(fd)) return -1;

    return 0;
}

and finally, in user-space/mux-tools are my Makefile and mux-tool.cpp:

CFLAGS= -ggdb -Wall
USER_INCLUDES= -I ../include

all: mux-tool

mux-tool: mux-tool.o
    $(CROSS_COMPILE)g++ $(CFLAGS) $(USER_INCLUDES) -o mux-tool ../system/usermux/usermux.o mux-tool.o

mux-tool.o: mux-tool.cpp
    $(CROSS_COMPILE)g++ $(CFLAGS) $(USER_INCLUDES) -c mux-tool.cpp

clean:
    rm -f mux-tool.o mux-tool

#include <system/usermux.h>

#include <cstdlib>
#include <iostream>

using namespace std;

void usage(char* name) {
    cout << "Usage: " << name << " address [mode input_enable pu_en pu_up]" << endl;
    cout << "\taddress: Address of pad config. Note that this utility uses half-word addresses" << endl;
    cout << "\tmode: Mux mode for the pin, 0-7" << endl;
    cout << "\tinput_enable: 1 to enable using pin as input, 0 otherwise" << endl;
    cout << "\tpu_en: 1 to enable the pull up/down, 0 to disable" << endl;
    cout << "\tpu_up: 1 to use pull up, 0 for pull down" << endl;
}

int main(int argc, char** argv) {

    MuxConfig mux;

    if (argc < 6) {
        if (argc < 2) {
            usage(argv[0]);
            exit(1);
        }

        mux.address = strtoul(argv[1], 0, 0);

        if (argc > 2) {
            mux.mode = atoi(argv[2]);
            mux.input_enable = atoi(argv[3]);
            mux.pullupdown_enable = atoi(argv[4]);
            mux.pullupdown_up = atoi(argv[5]);

            if (setmux(&mux)) {
                cerr << "Error setting mux configuration" << endl;
            } else {
                cout << "Mux set successfully." << endl;
            }
        } else {
            if (getmux(&mux)) {
                cerr << "Error reading mux configuration" << endl;
            } else {
                cout << "Mux config for address " << hex << mux.address << endl;
                cout << "\tMode: " << dec << mux.mode << endl;

                cout << "\tInput: ";
                if (mux.input_enable) {
                    cout << "enabled";
                } else {
                    cout << "disabled";
                }
                cout << endl;

                cout << "\tPull Up/Down: ";
                if (mux.pullupdown_enable) {
                    if (mux.pullupdown_up) {
                        cout << "up";
                    } else {
                        cout << "down";
                    }
                    cout << endl;
                } else {
                    cout << "disabled";
                }
                cout << endl;
            }
        }
    }
}
  • 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-30T18:08:00+00:00Added an answer on May 30, 2026 at 6:08 pm

    I believe your header file for the utility routines needs

    #ifdef __cplusplus
    extern "C" {
    #endif
    // ...
    #ifdef __cplusplus
    }
    #endif
    

    around it, either in the header file or around the #include. If you let the C++ compiler interpret the declarations without the extern "C", it will be expecting mangled names, and it won’t find the unmangled C symbols.

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

Sidebar

Related Questions

I get this error from my migration of NUnit to Team System when running
I get this 'error' when running PEVerify on a custom generated assembly. [MD](0x8013124C): Error:
When running wsdl.exe on a WSDL I created, I get this error: Error: Unable
I tried running a python script: print Hello, World! And I get this error:
I'm trying to get smartgit running on Ubuntu, and I'm constantly getting this error:
Why I get this error? Page not found (404) Using the URLconf defined in
I always get this error when trying to compile my file with Boost::GIL PNG
I get this error: Can't locate Foo.pm in @INC Is there an easier way
I get this error on an update panel within a popupControlExtender which is within
I get this error when I do an svn update : Working copy XXXXXXXX

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.