Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Symbol Undefined Errors

Moderators: kris

Posted: 02/13/07 08:52:58

I'm on Windows. Tango is configured properly and I can build and execute some tests. However, when using certain modules I get "Symbol Undefined" errors. I've encountered several while modifying Derelict's build script. Right now, though, I've given up on that and am just focusing on getting individual packages to compile into an app when using Bud.

I've done all of the wrapping and converting of code that I need to do, but now one Symbol Undefined error is standing in my way:

Error 42: Symbol Undefined _D5tango4text4Util7arrayZ

I can't for the life of me figure out how to solve that. From that module, I'm using trim, split, and locatePattern. Any hints?

Author Message

Posted: 02/13/07 09:53:40

Hmm, could you post a minimal example if possible?

And which compiler version and distribution of Tango did you use (downloads or trunk)?

Posted: 02/13/07 10:16:13 -- Modified: 02/13/07 10:17:54 by
aldacron

larsivi wrote:

Hmm, could you post a minimal example if possible?

I've tried to reduce this, but different variations compile fine, while others cause the error:

version(Tango)
{
	private
	{
		import tango.stdc.string;
		import tango.text.Util;
	}
}
else
{
	private
	{
		import std.string;
		import std.c.string;
	}
}

char* toCString(char[] str)
{
	version(Tango) 
	{
		return (str ~ "\0").ptr;
	}
	else
	{
		return str.toStringz();
	}	
}

int findStr(char[] str, char[] match)
{
	version(Tango)
	{
		int i = locatePattern(str, match);
		return (i == str.length) ? -1 : 0;
	}
	else
	{
		return str.find(match);
	}
}

char[] toDString(char* cstr)
{
	return (cstr is null) ? null : cstr[0 .. strlen(cstr)];
}

char[][] splitStr(char[] str, char[] delim)
{
	return split(str, delim);
}

char[] stripWhiteSpace(char[] str)
{
	version(Tango)
	{
		return trim(str);
	}
	else
	{
		return str.strip();
	}
}
void main()
{
	char[] s = "foo bar boo";
	char[][] ss = splitStr(s, " ");  // <-- This line will cause the error
	
        // int t = findStr(s, "bar");   // <-- This line will also cause the error 
}
larsivi wrote:

And which compiler version and distribution of Tango did you use (downloads or trunk)?

DMD 1.005, latest Tango trunk. I'll switch to the download version and see if that makes a difference.

Posted: 02/13/07 10:22:06

Note that you have fromUtf8z and toUtf8z in tango.stdc.stringz.

Posted: 02/13/07 10:22:11

I just tried with the download version. After editing the code to use demarcate() in place of split, I get the same error.

Posted: 02/14/07 13:17:27

Okay, I've just confirmed that the error doesn't happen when compiling with Rebuild.

Posted: 02/14/07 13:20:46

Weird, this hasn't been reported by anyone else, but it does suggest a possible default recommended build tool.

Posted: 02/14/07 16:44:24

Sorry, Mike.

But I'd recommend a tool change. "rebuild" has been tested quite heavily by a number of people (and most notably with Tango), and the bug-fix turn around is currently excellent. It's also more likely to work well on platforms on which dmd doesn't exist (meaning gdc oriented platforms like Mac OSX). rebuild also spits out fully-qualified object names, which is a huge bonus for clarity and conflict-elimination.

"rebuild" is the tool I use to test Tango's latest updates on 3 platforms (GDC/linux, DMD/Linux, DMD/win32; soon DMD/Mingw). Bud has it's place, but it hasn't been working consistantly with the gdc based tools, and i don't think people are using it to test Tango.

Posted: 03/08/07 10:51:18

it appears that this and similar errors occur if you use the (very dangerous) option -od (or whatever it is for a given build tool) that puts all object files into a single directory non-unique filenames. object files get overwritten like this... use -oq for rebuild instead. bud would use -op, but it doesn't seem to be working there.

in this example the problem might be another util.obj from the project. in my case it was Layout.obj from tango.text.convert as well as tango.util.log

Posted: 03/08/07 19:04:55

With rebuild, you don't have to use -oq; you use that switch only if you want to send objects to a specified output directory. By default, rebuild outputs fully-qualified objects in the current directory (ie, no switch required).

Posted: 04/19/07 21:57:58

Hello,

I have the same error:

>D:\dproggen\DScite\bud.exe -DCPATHD:\dproggen\DScite\dm\bin\make -ID:\dproggen\DScite\dmd\lib -ID:\dproggen\DScite\libraries   -I..\.. main.d
OPTLINK (R) for Win32  Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved
   
D:\dproggen\DScite\libraries\derelict\util\wrapper.obj(wrapper) 
 Error 42: Symbol Undefined _D5tango4text4Util7__arrayZ
>Exit code: 1

Don t know how to fix it. I downloaded "tango-0.97-bin-win32-dmd.1.012"! its included in my PATH, too. I use DScite and just click on "compile". The above errors apppeared. maybe my sc.ini:

[Version]
version=7.51 Build 020

[Environment]
LIB="%@P%\..\lib"
DFLAGS="-I%@P%\..\import" -version=Tango -L+tango.lib
LINKCMD=%@P%\link.exe

would really like to use Derelict and Tango! Here is my sample code from nehe:

/**
 * The 6th lesson in the <a href="http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=06">NeHe tutorial series</a>.
 * Originally written by Jeff Molofee.
 *
 * Authors: Jeff Molofee
 *          Olli Aalto
 */
module lesson01;

import derelict.opengl.gl;
import derelict.opengl.glu;
import derelict.sdl.sdl;

import tango.stdc.stringz;

/// The window title
const char[] WINDOW_TITLE = "NeHe's Texture Mapping Tutorial (D version)";

/// The main loop flag
bool running;

/// X Rotation
GLfloat xrot = 0.0f;
/// Y Rotation
GLfloat yrot = 0.0f;
/// Z Rotation
GLfloat zrot = 0.0f;

/// Storage For One Texture
GLuint texture;

/**
 * Module constructor. Here we load the GL, GLU and SDL shared libraries,
 * and the initialize SDL.
 */
static this()
{
    DerelictGL.load();
    DerelictGLU.load();
    DerelictSDL.load();

    if (SDL_Init(SDL_INIT_VIDEO) < 0)
    {
        throw new Exception("Failed to initialize SDL: " ~ getSDLError());
    }
}

/**
 * Module destructor. SDL_Quit must be called somewhere, and as we initialized
 * it in the module constructor so the module destructor should be a suitable
 * place.
 */
static ~this()
{
    SDL_Quit();
}

/**
 * The main function. This is where the fun begins. The first order of business
 * is the check the command line arguments if the user wanted to start in
 * fullscreen mode. Then the window is created and OpenGL is initialized with
 * basic settings. Finally the the function starts the main loop which will live
 * for the duration of the application.
 *
 * Params:
 *      args = the command line arguments
 */
void main(char[][] args)
{
    bool fullScreen = false;
    if (args.length > 1)
    {
        fullScreen = args[1] == "-fullscreen";
    }

    createGLWindow(WINDOW_TITLE, 640, 480, 16, fullScreen);
    initGL();

    running = true;
    while (running)
    {
        processEvents();

        drawGLScene();

        SDL_GL_SwapBuffers();
        SDL_Delay(10);
    }
}

/**
 * Load the texture used in this tutorial.
 */
void loadGLTexture()
{
    SDL_Surface *textureImage;

    // Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
    if ((textureImage = SDL_LoadBMP("data/NeHe.bmp")) !is null)
    {
        // Free the surface when exiting the scope
        scope(exit) SDL_FreeSurface(textureImage);

	    // Create The Texture
	    glGenTextures(1, &texture);

	    // Create Nearest Filtered Texture
	    glBindTexture(GL_TEXTURE_2D, texture);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		glTexImage2D(GL_TEXTURE_2D, 0, 3, textureImage.w, textureImage.h, 0, GL_BGR,
            GL_UNSIGNED_BYTE, textureImage.pixels);
    }
}

/**
 * Process all the pending events.
 */
void processEvents()
{
    SDL_Event event;
    while (SDL_PollEvent(&event))
    {
        switch (event.type)
        {
            case SDL_KEYUP:
                keyReleased(event.key.keysym.sym);
                break;
            case SDL_QUIT:
                running = false;
                break;
            default:
                break;
        }
    }
}

/**
 * Process a key released event.
 */
void keyReleased(int key)
{
    switch (key)
    {
        case SDLK_ESCAPE:
            running = false;
            break;
        default:
            break;
    }
}

/**
 * Resize and initialize the OpenGL window.
 */
void resizeGLScene(GLsizei width, GLsizei height)
{
    if (height == 0)
	{
		height = 1;
	}

    // Reset The Current Viewport
	glViewport(0, 0, width, height);

    // Select The Projection Matrix
	glMatrixMode(GL_PROJECTION);

	// Reset The Projection Matrix
	glLoadIdentity();

	// Calculate The Aspect Ratio Of The Window
	gluPerspective(45.0f, cast(GLfloat)width / cast(GLfloat)height,
        0.1f, 100.0f);

    // Select The Modelview Matrix
	glMatrixMode(GL_MODELVIEW);

	// Reset The Modelview Matrix
	glLoadIdentity();
}

/**
 * Initialize OpenGL.
 */
void initGL()
{
    // Load the texture
    loadGLTexture();
    // Enable Texture Mapping
    glEnable(GL_TEXTURE_2D);
    // Enables Smooth Shading
    glShadeModel(GL_SMOOTH);
    // Black Background
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    // Depth Buffer Setup
    glClearDepth(1.0f);
    // Enables Depth Testing
	glEnable(GL_DEPTH_TEST);
	// The Type Of Depth Test To Do
	glDepthFunc(GL_LEQUAL);
	// Really Nice Perspective Calculations
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    // Change to texture matrix and flip and rotate the texture
    glMatrixMode(GL_TEXTURE);
    glRotatef(180.0f, 0.0f, 0.0f, 1.0f);
    glScalef(-1.0f, 1.0f, 1.0f);
    // Back to normal
    glMatrixMode(GL_MODELVIEW);
}

/**
 * The drawing function. Now we only clear the color and depht buffers, so that
 * the window stays black.
 */
void drawGLScene()
{
}

/**
 * Initializes and opens the SDL window.
 */
void createGLWindow(char[] title, int width, int height, int bits,
    bool fullScreen)
{
    // Set the OpenGL attributes
    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

    // Set the window title
    SDL_WM_SetCaption(toUtf8z(title), null);

    // Note the SDL_DOUBLEBUF flag is not required to enable double
    // buffering when setting an OpenGL video mode.
    // Double buffering is enabled or disabled using the
    // SDL_GL_DOUBLEBUFFER attribute. (See above.)
    int mode = SDL_OPENGL;
    if (fullScreen)
    {
        mode |= SDL_FULLSCREEN;
    }

    // Now open a SDL OpenGL window with the given parameters
    if (SDL_SetVideoMode(width, height, bits, mode) is null)
    {
        throw new Exception("Failed to open OpenGL window: " ~ getSDLError());
    }

    resizeGLScene(width, height);
}

/**
 * Get the SDL error as a D string.
 *
 * Returns: A D string containing the current SDL error.
 */
char[] getSDLError()
{
    return fromUtf8z(SDL_GetError());
}

Posted: 04/20/07 08:59:06 -- Modified: 04/20/07 08:59:42 by
Zweistein

somebody in the irc Channel gave me the Tip to use DSSS (rebuild) tool. That worked for me. maybe BUD have to be fixed?

MFG