LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-03-2017, 11:43 AM   #1
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (current), FreeBSD, Win10, It varies
Posts: 9,952

Rep: Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148
dockapp.c:(.text+0x679): undefined reference to `XShapeCombineMask'


I got it down to this and I am still not getting this thing to see

<X11/extensions/shape.h>

does anyone know if their is a cli directive in the gcc line or what I got do to get it to actually look at the shape.h?
Code:
/usr/include/xcb/shape.h
userx@voider⚡~/Downloads/wmgtemp-1.2/src $gcc  -Wall -lX11 -lXpm dockapp.c
/usr/lib/gcc/x86_64-unknown-linux-gnu/6.3.0/../../../../lib/crt1.o: In function `_start':
/builddir/glibc-2.25/csu/../sysdeps/x86_64/start.S:110: undefined reference to `main'
/tmp/ccmliMEn.o: In function `dockapp_set_shape':
dockapp.c:(.text+0x679): undefined reference to `XShapeCombineMask'
dockapp.c:(.text+0x6b9): undefined reference to `XShapeCombineMask'
Code:
#include <X11/Xlib.h>
#include <X11/xpm.h>
#include <X11/extensions/shape.h>

#include "/home/userx/Downloads/wmgtemp-1.2/src/dockapp.h"
 
Old 04-03-2017, 12:40 PM   #2
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Try adding:
Code:
-lxext
 
Old 04-03-2017, 12:52 PM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (current), FreeBSD, Win10, It varies
Posts: 9,952

Original Poster
Rep: Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148
Quote:
Originally Posted by norobro View Post
Try adding:
Code:
-lxext
changed it to
Code:
-lXext
and it got me this now ..
Code:
userx@voider⚡~/Downloads/wmgtemp-1.2/src $gcc -Wall -lX11 -lXpm -lXext dockapp.c
/usr/lib/gcc/x86_64-unknown-linux-gnu/6.3.0/../../../../lib/crt1.o: In function `_start':
/builddir/glibc-2.25/csu/../sysdeps/x86_64/start.S:110: undefined reference to `main'
collect2: error: ld returned 1 exit status
though it did get rid of the thing I asked about. thanks!>
 
Old 04-03-2017, 03:46 PM   #4
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
I have to ask: Do you have a main function in dockapp.c?
 
Old 04-03-2017, 04:18 PM   #5
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (current), FreeBSD, Win10, It varies
Posts: 9,952

Original Poster
Rep: Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148
Quote:
Originally Posted by norobro View Post
I have to ask: Do you have a main function in dockapp.c?

Code:
userx@voider⚡~/Downloads/wmgtemp-1.2/src $gcc -Wall -lX11 -lXpm -lXext dockapp.c
/usr/lib/gcc/x86_64-unknown-linux-gnu/6.3.0/../../../../lib/crt1.o: In function `_start':
/builddir/glibc-2.25/csu/../sysdeps/x86_64/start.S:110: undefined reference to `main'
collect2: error: ld returned 1 exit status
their is no "main' function in dockapp.c just other functions.

it is in a fuction called _start but it looks like it is speaking of something within /lib/crt1.o : in function _start - that their is an undefined reference to 'main'

or it is in glibc-2.25 .../sysdeps/x86_64/start

not dockapp.c

Last edited by BW-userx; 04-03-2017 at 04:26 PM.
 
Old 04-03-2017, 04:26 PM   #6
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
You'll get that error with out main(). Here is the the output trying to compile an empty file on my box:
Code:
~/test $ touch main.c
~/test $ cc main.c 
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
Can you post dockapp.c?
 
Old 04-03-2017, 04:29 PM   #7
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (current), FreeBSD, Win10, It varies
Posts: 9,952

Original Poster
Rep: Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148
Quote:
Originally Posted by norobro View Post
You'll get that error with out main(). Here is the the output trying to compile an empty file on my box:
Code:
~/test $ touch main.c
~/test $ cc main.c 
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
Can you post dockapp.c?
Code:
/*
 * Copyright (c) 1999 Alfredo K. Kojima
 * Copyright (c) 2001, 2002 Seiichi SATO
 * Copyright (c) 2007 Daniel Borca
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */


#include <X11/Xlib.h>
#include <X11/xpm.h>
#include <X11/extensions/shape.h>

#include "/home/userx/Downloads/wmgtemp-1.2/src/dockapp.h"


#define WINDOWED_SIZE_W 64
#define WINDOWED_SIZE_H 64
#define DOCKED_SIZE_W   (WINDOWED_SIZE_W - 4)
#define DOCKED_SIZE_H   (WINDOWED_SIZE_H - 4)


int
dockapp_open_window(DOCKAPP *d,
		    const char *display_specified,
		    char *appname, int iswindowed,
		    int argc, char **argv)
{
    XSizeHints sizehints;
    XClassHint classhint;
    XWMHints wmhints;
    XTextProperty title;
    Window root;
    int ww, wh;

    /* Open Connection to X Server */
    d->display = XOpenDisplay(display_specified);
    if (d->display == NULL) {
	return -1;
    }

    d->x_offset = d->y_offset = 0;
    ww = DOCKED_SIZE_W;
    wh = DOCKED_SIZE_H;
    if (iswindowed) {
	d->x_offset = (WINDOWED_SIZE_W - DOCKED_SIZE_W) / 2;
	d->y_offset = (WINDOWED_SIZE_H - DOCKED_SIZE_H) / 2;
	ww = WINDOWED_SIZE_W;
	wh = WINDOWED_SIZE_H;
    }

    /* Create Windows */
    root = DefaultRootWindow(d->display);
    d->icon_window = XCreateSimpleWindow(d->display, root, 0, 0, ww, wh, 0, 0, 0);
    d->window = XCreateSimpleWindow(d->display, root, 0, 0, 1, 1, 0, 0, 0);

    /* Set ClassHint */
    classhint.res_class = "DockApp";
    classhint.res_name = appname;
    XSetClassHint(d->display, d->window, &classhint);

    /* Set WMHints */
    wmhints.flags = IconWindowHint | WindowGroupHint;
    if (!iswindowed) {
	wmhints.flags |= StateHint;
	wmhints.initial_state = WithdrawnState;
    }
    wmhints.window_group = d->window;
    wmhints.icon_window = d->icon_window;
    XSetWMHints(d->display, d->window, &wmhints);

    /* Set Size Hints */
    sizehints.flags = USSize;
    if (!iswindowed) {
	sizehints.flags |= USPosition;
	sizehints.x = sizehints.y = 0;
    } else {
	sizehints.flags |= PMinSize | PMaxSize;
	sizehints.min_width = sizehints.max_width = WINDOWED_SIZE_W;
	sizehints.min_height = sizehints.max_height = WINDOWED_SIZE_H;
    }
    sizehints.width = ww;
    sizehints.height = wh;
    XSetWMNormalHints(d->display, d->icon_window, &sizehints);

    /* Set WindowTitle for AfterStep Wharf */
    XStringListToTextProperty(&appname, 1, &title);
    XSetWMName(d->display, d->window, &title);
    XSetWMName(d->display, d->icon_window, &title);
    XFree(title.value);

    /* Set WM Protocols */
    d->delete_win = XInternAtom(d->display, "WM_DELETE_WINDOW", False);
    XSetWMProtocols(d->display, d->icon_window, &d->delete_win, 1);

    /* Set Command to start the app so it can be docked properly */
    XSetCommand(d->display, d->window, argv, argc);

    d->width = DOCKED_SIZE_W;
    d->height = DOCKED_SIZE_H;
    d->iswindowed = iswindowed;
    d->depth = DefaultDepth(d->display, DefaultScreen(d->display));
    d->gc = DefaultGC(d->display, DefaultScreen(d->display));

    d->quit = False;
    d->pixmap = dockapp_createpixmap(d, ww, wh);
    XSetForeground(d->display, d->gc, dockapp_get_color(d, "rgb:ae/aa/ae"));
    XFillRectangle(d->display, d->pixmap, d->gc, 0, 0, ww, wh);
    XSetWindowBackgroundPixmap(d->display, d->icon_window, d->pixmap);
    XSetWindowBackgroundPixmap(d->display, d->window, d->pixmap);
    XClearWindow(d->display, d->icon_window);

    if (!d->iswindowed) {
	XMapRaised(d->display, d->window);
    } else {
	XMapRaised(d->display, d->icon_window);
    }

    XFlush(d->display);

    return 0;
}


void
dockapp_set_eventmask(const DOCKAPP *d, long mask)
{
    XSelectInput(d->display, d->icon_window, mask);
    XSelectInput(d->display, d->window, mask);
}


void
dockapp_set_shape(const DOCKAPP *d, Pixmap mask)
{
    XShapeCombineMask(d->display, d->icon_window, ShapeBounding,
		      d->x_offset, d->y_offset, mask, ShapeSet);
    XShapeCombineMask(d->display, d->window, ShapeBounding,
		      d->x_offset, d->y_offset, mask, ShapeSet);
    XFlush(d->display);
}


void
dockapp_copy_area(const DOCKAPP *d,
		  Pixmap src,
		  int x_src, int y_src, int w, int h, int x_dst, int y_dst)
{
    XCopyArea(d->display, src, d->pixmap, d->gc, x_src, y_src, w, h, x_dst + d->x_offset, y_dst + d->y_offset);
}


void
dockapp_update(const DOCKAPP *d)
{
    XClearWindow(d->display, d->icon_window);
}


Bool
dockapp_xpm2pixmap(const DOCKAPP *d,
		   char **data, Pixmap *pixmap, Pixmap *mask,
		   XpmColorSymbol *colorSymbol, unsigned int nsymbols)
{
    XpmAttributes xpmAttr;
    xpmAttr.valuemask = XpmCloseness;
    xpmAttr.closeness = 1 << 15;

    if (nsymbols) {
	xpmAttr.colorsymbols = colorSymbol;
	xpmAttr.numsymbols = nsymbols;
	xpmAttr.valuemask |= XpmColorSymbols;
    }

    return (XpmCreatePixmapFromData(d->display, d->icon_window, data, pixmap, mask, &xpmAttr) == 0);
}


Pixmap
dockapp_createpixmap(const DOCKAPP *d, int width, int height)
{
    return XCreatePixmap(d->display, d->icon_window, width, height, d->depth);
}


Bool
dockapp_nextevent_or_timeout(DOCKAPP *d,
			     XEvent *event, unsigned long millis)
{
    struct timeval timeout;
    fd_set rset;

    XSync(d->display, False);
    if (XPending(d->display)) {
	XNextEvent(d->display, event);
	return True;
    }

    timeout.tv_sec = millis / 1000;
    timeout.tv_usec = (millis % 1000) * 1000;

    FD_ZERO(&rset);
    FD_SET(ConnectionNumber(d->display), &rset);
    if (select(ConnectionNumber(d->display) + 1, &rset, NULL, NULL, &timeout) > 0) {
	XNextEvent(d->display, event);
	if (event->type == ClientMessage) {
	    if ((Atom)event->xclient.data.l[0] == d->delete_win) {
		d->quit = True;
		return False;
	    }
	}
	if (d->iswindowed) {
	    event->xbutton.x -= d->x_offset;
	    event->xbutton.y -= d->y_offset;
	}
	return True;
    }

    return False;
}


unsigned long
dockapp_get_color(const DOCKAPP *d, const char *color_name)
{
    XColor color;

    if (!XParseColor(d->display, DefaultColormap(d->display, DefaultScreen(d->display)), color_name, &color)) {
	return BlackPixel(d->display, DefaultScreen(d->display));
    }

    if (!XAllocColor(d->display, DefaultColormap(d->display, DefaultScreen(d->display)), &color)) {
	return BlackPixel(d->display, DefaultScreen(d->display));
    }

    return color.pixel;
}
header maybe over kill but their a matched set.
Code:
/*
 * Copyright (c) 1999 Alfredo K. Kojima
 * Copyright (c) 2001, 2002 Seiichi SATO
 * Copyright (c) 2007 Daniel Borca
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */


#ifndef DOCKAPP_H_included
#define DOCKAPP_H_included

typedef struct {
    Display *display;
    Bool iswindowed;
    Pixmap pixmap;
    Bool quit;

    Window window;
    Window icon_window;
    GC gc;
    int depth;
    Atom delete_win;
    int width, height;
    int x_offset, y_offset;
} DOCKAPP;

int dockapp_open_window(DOCKAPP *d,
			const char *display_specified,
			char *appname, int iswindowed,
			int argc, char **argv);

void dockapp_set_eventmask(const DOCKAPP *d, long mask);

void dockapp_set_shape(const DOCKAPP *d, Pixmap mask);

void dockapp_copy_area(const DOCKAPP *d,
		      Pixmap src,
		      int x_src, int y_src, int w, int h, int x_dst, int y_dst);

void dockapp_update(const DOCKAPP *d);

Bool dockapp_xpm2pixmap(const DOCKAPP *d,
			char **data, Pixmap *pixmap, Pixmap *mask,
			XpmColorSymbol *colorSymbol, unsigned int nsymbols);

Pixmap dockapp_createpixmap(const DOCKAPP *d, int width, int height);

Bool dockapp_nextevent_or_timeout(DOCKAPP *d,
				  XEvent *event, unsigned long millis);

unsigned long dockapp_get_color(const DOCKAPP *d, const char *color);

#endif

Last edited by BW-userx; 04-03-2017 at 04:32 PM.
 
Old 04-03-2017, 04:40 PM   #8
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
That's just a bunch of functions that have to be called somewhere.

Where did you get that file?
Did you look at wmgtemp.c in wmgtemp-1.2/src?
 
Old 04-03-2017, 04:47 PM   #9
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (current), FreeBSD, Win10, It varies
Posts: 9,952

Original Poster
Rep: Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148
Quote:
Originally Posted by norobro View Post
That's just a bunch of functions that have to be called somewhere.

Where did you get that file?
Did you look at wmgtemp.c in wmgtemp-1.2/src?
pulled it out of a different docapp because wmgtemp calls for it too. so I was trying to get wmgtemp.c to see its header but it would so I went to trying to see if i could compile dockapp.c


I didn't do any recon on this before starting mind you. but it should compile into an o file


MOD
I just googled this
Code:
Search Results
Can we compile C program without main?
4 Answers 4. On GCC, the -c switch is what you want ( -c means
 "compile, don't link" and you get an name.o output file). ... You 
can compile individual files without main , but you cannot link them 
and of course cannot run them since they are not complete programs.
let me try that -c switch

Last edited by BW-userx; 04-03-2017 at 04:52 PM.
 
Old 04-03-2017, 04:56 PM   #10
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (current), FreeBSD, Win10, It varies
Posts: 9,952

Original Poster
Rep: Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148
that was it. after all of the other switches needed too.

Code:
userx@voider⚡~/Downloads/wmgtemp-1.2/src $ls
dockapp.c  dockapp.o                   wmgtemp-interface.xpm
dockapp.h  wmgtemp-interface-mask.xbm  wmgtemp.c
 
Old 04-03-2017, 04:57 PM   #11
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
If you want an object file use the "-c" switch.

Maybe a brief description of what you are doing will help. Are you trying to integrate these functions into wmgtemp?

EDIT: Didn't refresh before posting.

Last edited by norobro; 04-03-2017 at 05:10 PM.
 
Old 04-03-2017, 05:23 PM   #12
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (current), FreeBSD, Win10, It varies
Posts: 9,952

Original Poster
Rep: Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148
Quote:
Originally Posted by norobro View Post
If you want an object file use the "-c" switch.

Maybe a brief description of what you are doing will help. Are you trying to integrate these functions into wmgtemp?

EDIT: Didn't refresh before posting.
yeap I am shooting in the dark Just so you know.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ undefined reference grob115 Programming 4 01-22-2013 11:22 AM
Error in compilation : (.text+0x3e2): undefined reference to `elf_setshstrndx' fright Programming 4 11-08-2012 08:38 AM
undefined reference to... dimah Programming 3 12-27-2006 09:57 AM
Undefined reference to: ashlesha Programming 5 11-08-2006 01:07 PM
undefined reference? Sharky01252 Programming 3 11-07-2006 11:36 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration