undefined reference to `GPIOSetDir'

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

undefined reference to `GPIOSetDir'

1,931件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by woodchuck on Thu Jul 29 14:22:41 MST 2010
To control the LED on my LPCxpresso board, I make GPIO references just like the sample code does.  Unfortunately the linker keeps flagging them.  I'm putting the gpio.h header file right next to the main.c file in the src folder but it STILL does not help.  Naturally, in main.c (on about line 8) I have the following: #include "gpio.h"

What in the world is going on?  How can I make it any more obvious to the compiler/linker?  Spending an hour on a stupid problem like this is mighty annoying!!!
0 件の賞賛
19 返答(返信)

1,800件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Mon Jul 23 11:06:31 MST 2012
xOrElse,

Why did you post here in this very old thread?:confused:

Learn to make your own thread instead of posting in an existing thread.:)
0 件の賞賛

1,800件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xOrElse on Mon Jul 23 09:01:09 MST 2012
Tnx! Much clearer now :rolleyes:
0 件の賞賛

1,800件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ex-kayoda on Mon Jul 23 04:42:22 MST 2012
CMSIS is supporting you with a few useful things :)

#1 stdint.h which defines integer stuff like uint32_t

stdint.h is included in system_LPC13xx.h, which is included (surprise) in LPC13xx.h ;)

#2 A lot of structs, which are defined in (surprise) LPC13xx.h ;)

So it's always a good idea to check inclusion of this header file if you are using CMSIS based projects and compiler is nagging :rolleyes:
0 件の賞賛

1,800件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xOrElse on Mon Jul 23 04:00:45 MST 2012
Thank you!!! It's working now!

Could you explain why I had to add  that?
0 件の賞賛

1,800件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ex-kayoda on Mon Jul 23 03:27:28 MST 2012
Then add
#include "lpc13xx.h"
to your gpio.h
0 件の賞賛

1,800件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xOrElse on Mon Jul 23 03:11:44 MST 2012
Uh, ok, I'll try to do this again
0 件の賞賛

1,800件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ex-kayoda on Mon Jul 23 03:08:25 MST 2012

Quote: xOrElse
Sorry, I didn't see that they're so small...

here is link



And can't read your link :confused:
0 件の賞賛

1,800件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xOrElse on Mon Jul 23 02:49:20 MST 2012

Quote: kayoda
Sorry, can't read 425 x 272 jpgs :eek:



Sorry, I didn't see that they're so small...

here is link
0 件の賞賛

1,800件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ex-kayoda on Mon Jul 23 02:40:54 MST 2012

Quote: xOrElse
Well I thought it's not a big problem, but here are pic's what happens when I do that:



Sorry, can't read 425 x 272 jpgs :eek:
0 件の賞賛

1,800件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xOrElse on Mon Jul 23 02:37:22 MST 2012
Well I thought it's not a big problem, but here are pic's what happens when I do that:
0 件の賞賛

1,800件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ex-kayoda on Mon Jul 23 02:24:45 MST 2012
And what's the problem now :confused:

drugie.c should include drugi.h (does it?), and drugi.h should include gpio.h :)

So gpio functions are declared in drugie.c :rolleyes:
0 件の賞賛

1,800件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xOrElse on Mon Jul 23 01:52:20 MST 2012
Hello,
I would like to make a multi-file project (just for learning). Actually I already did that, but the problem is when I want to use dome GPIO funkctions in other .c files (in main.c it works ok). Where should I write and what should I write?

This is what I did:
-main.c some simple code for turning off led<-this works
-drugie.c looks like this:

volatile int crveni=0;

void Funkcija (){
    GPIOSetValue(3,3,1);
}
-drugi.h looks like this:

#ifndef DRUGI_H_
#define DRUGI_H_

extern volatile int crveni;
#include "gpio.h"

void Funkcija (void);
#endif 
-gpio.h and gpio.h are the same as in examples from nxp site.


I'm using lpc1343
0 件の賞賛

1,800件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by woodchuck on Fri Jul 30 13:37:55 MST 2010
One other thing...whenever I create a new project, I always specify "NXP LPC1110 (or 1300) Simple C project."  Never have I tried the "Hello World (semihosting)" project type.  Also, I always click that I want to include the CMSIS library.
0 件の賞賛

1,800件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by woodchuck on Fri Jul 30 13:20:39 MST 2010

Quote: CodeRedSupport
The gpio functionality (and a bunch of other stuff) is included in the CMSISxxx library. You need to link with the library for it to be found.

You don't mention which LPCXpresso you are using. I am going to assume LPC1114.

Select your project, right-click and select Properties.
In the Properties dialog, open C/C++ Build and then Settings
Now, in the Tools Settings Tab, click on Libraries underneath MCU Linker
Under Libraries(-l) add CMSISv1p30_LPC11xx
Under Library Search path (-L) add "${workspace_loc:/CMSISv1p30_LPC11xx/Debug}"

Now, this library will be linked with you application.


Many thanks for your help!

In my workspace, I have both LPC1114 and LPC1343 projects.  And I've encountered this same problem with both boards, whenever it involves GPIO.

I followed the path you outlined (which disclosed a part of the IDE I'd never seen or visited before).  I found that the proper CMSIS library was already included.

FWIW, under the Quickstart panel I had previously poked around the Quick Settings and had, in the process of comparing my project with other projects, added a second include path, but it didn't fix the problem.

Time after time I get the same error messages, that I'm making undefined referrences to various GPIO functions, like GPIOSetDir and GPIOSetValue.

Is there a workaround that avoids this formalism?  Some sort of expression that will allow me to toggle I/O lines w/o the need of libraries?

One other tidbit of info:  I have, with both the 1114 and 1343, eventually (after an hour or more of dinking around) been able to build and run programs I've written that contain GPIO references.  But I've never been able to determine what it was that made the difference.  There's nothing I can see different between sample code, code of mine that now runs, and code of mine that doesn't run.

Anyway, thank you for your time.  I'll keep poking around this new area - the Properties area -of various projects.  Who knows what crazy thing will turn up!?
0 件の賞賛

1,800件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Fri Jul 30 09:44:36 MST 2010
The gpio functionality (and a bunch of other stuff) is included in the CMSISxxx library. You need to link with the library for it to be found.

You don't mention which LPCXpresso you are using. I am going to assume LPC1114.

Select your project, right-click and select Properties.
In the Properties dialog, open C/C++ Build and then Settings
Now, in the Tools Settings Tab, click on Libraries underneath MCU Linker
Under Libraries(-l) add CMSISv1p30_LPC11xx
Under Library Search path (-L) add "${workspace_loc:/CMSISv1p30_LPC11xx/Debug}"

Now, this library will be linked with you application.
0 件の賞賛

1,800件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by woodchuck on Fri Jul 30 07:50:26 MST 2010

Quote: NXP_USA
Is the gpio.c file included in your project? If so, check that its icon matches the other .c files. If the icon is different, it may be excluded from the build. This can be fixed with the right-click menu exclude from build option.


I added gpio.c to my src folder, but the results were the same, ie, no worky.  Also, I note that similar working examples often have neither gpio.c nor gpio.h in their src folder.  It's all voodoo to me at this point.  Frustrating voodoo.
0 件の賞賛

1,800件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by woodchuck on Fri Jul 30 07:47:29 MST 2010

Quote: CodeRedSupport
This sounds like you haven't linked with the support library. Take a closer look at the Linker settings in the example that works and make sure your one matches it.


I suspect your diagnosis is exactly right.  Where do I find the linker settings?  So far, my search for 'Linker' anything has come up empty.
0 件の賞賛

1,800件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Fri Jul 30 00:13:55 MST 2010
This sounds like you haven't linked with the support library. Take a closer look at the Linker settings in the example that works and make sure your one matches it.
0 件の賞賛

1,800件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_USA on Thu Jul 29 15:19:14 MST 2010
Is the gpio.c file included in your project? If so, check that its icon matches the other .c files. If the icon is different, it may be excluded from the build. This can be fixed with the right-click menu exclude from build option.
0 件の賞賛