Homebrew Homebrew Development

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
I am doing these things, however, i don't have a libhi.h file that includes all other files, i include the different .h files manually.
for example when i need the class Circle then i do:
#include<libhi/circle.h>
where the libhi is a folder inside the include folder with circle.h in it.

The problem is that the .a file doesn't get read.
 

Coto

-
Member
Joined
Jun 4, 2010
Messages
2,979
Trophies
2
XP
2,565
Country
Chile
how to build a header:

//header.h
Code:
#ifdef __cplusplus
extern "C" {
#endif

extern int do_divide(int a,int b);

#ifdef __cplusplus
}
#endif

//header.c
Code:
#include "header.h"

int do_divide(int a,int b){

return (int)(a/b);
}


//someotherpartofprogram.c
Code:
#include "header.h"

void program(){
printf("16/2 = %d",do_divide(16,2));
}
So when you compile header.c an object (.o) will be generated. The linker expects a symbol declaration that matches the function signature so it can be reachable. If not found and you are using it somewhere you will get "undefined reference to _whatever".

edit:
(GNU uses the -I followed by the dir of the current Includes folder (.h)", make sure you have those at compile(g++/cc) and link(ld) time.


also if you suspect the library is not being recognized try:

Code:
ar -x libhi.a

that will extract the generated objects.
-
and if you want to re-build the library from many objects (.o):
Code:
ar rvs libhi.a object1.o object2.o ...

But you will need ar tool : (devkitPro\devkitARM\arm-none-eabi\bin)


Also I am not sure the libs linked in devkitarm are recursively read each folder, so subfolder library linking may not work.

With these tips you should understand pretty well how to build your libraries. If you still don't understand then try reading again.
 
Last edited by Coto, , Reason: added compile / linker info
  • Like
Reactions: Deleted User

Tjessx

Well-Known Member
Member
Joined
Dec 3, 2014
Messages
1,160
Trophies
0
Age
27
XP
952
Country
Belgium
I do follow those guidelines, maybe it is my homebrew environment.
Would someone want to try this library, and see if he/she can build it?
(link removed)

Include guinow.h, and execute this function in the int main():
GP::Graphics::init();
If that compiles, then everything should work

EDIT: i do not use the extern tag in the header files, is that necessary?
 
Last edited by Tjessx, , Reason: removed link

WiiUBricker

News Police
Banned
Joined
Sep 19, 2009
Messages
7,827
Trophies
0
Location
Espresso
XP
7,510
Country
Argentina
I am trying to compile a sample template I have found here. I followed all the steps but it fails every time to compile:

Code:
make.c
arm-none-eabi-gcc -MMD -MP -MF /c/devkitPro/3DS/template/build/main.d -g -Wall -O2 -mword-relocations -fomit-frame-pointer -ffast-math -march=armv6k -mtune=mpcore -mfloat-abi=softfp -I/c/devkitPro/3DS/template/include -I/c/devkitPro/libctru/include -I/c/devkitPro/3DS/template/build -DARM11 -D_3DS -c /c/devkitPro/3DS/template/source/main.c -o main.o
c:/devkitPro/3DS/template/source/main.c: In function 'main':
c:/devkitPro/3DS/template/source/main.c:10:3: error: too many arguments to function 'hidInit'
   hidInit(NULL);    // input
   ^
In file included from c:/devkitPro/libctru/include/3ds.h:40:0,
                 from c:/devkitPro/3DS/template/source/main.c:3:
c:/devkitPro/libctru/include/3ds/services/hid.h:89:8: note: declared here
Result hidInit(void);
        ^
c:/devkitPro/3DS/template/source/main.c:11:3: error: too few arguments to function 'gfxInit'
   gfxInit();        // graphics
   ^
In file included from c:/devkitPro/libctru/include/3ds.h:20:0,
                 from c:/devkitPro/3DS/template/source/main.c:3:
c:/devkitPro/libctru/include/3ds/gfx.h:66:6: note: declared here
void gfxInit(GSPGPU_FramebufferFormats topFormat, GSPGPU_FramebufferFormats bottomFormat, bool vrambuffers);
      ^
c:/devkitPro/3DS/template/source/main.c:15:7: warning: variable 'kUp' set but not used [-Wunused-but-set-variable]
   u32 kUp;          // keys up
       ^
c:/devkitPro/3DS/template/source/main.c:14:7: warning: variable 'kHeld' set but not used [-Wunused-but-set-variable]
   u32 kHeld;        // keys pressed
       ^
make[1]: *** [main.o] Error 1
"make": *** [build] Error 2

> Process Exit Code: 2
> Time Taken: 00:00

Any help is greatly appreciated.
 

Spaqin

Well-Known Member
Member
Joined
Feb 17, 2015
Messages
123
Trophies
0
Age
29
XP
199
Country
Poland
Remove arguments from hidInit and set up your gfxInit with proper arguments, or swap it for gfxInitDefault().
 

erman1337

Well-Known Member
Member
Joined
Sep 27, 2015
Messages
1,211
Trophies
0
Location
Brussels
XP
983
Country
Belgium
I still don't quite understand how to download something from sockets. Do I basically do this?:

Code:
while(socket buffer length > 0){
  receive from socket();
}

I know about the headers and stuff, I just need to know if this is what I need to do.
 

Rinnegatamante

Well-Known Member
Member
Joined
Nov 24, 2014
Messages
3,162
Trophies
2
Age
29
Location
Bologna
Website
rinnegatamante.it
XP
4,857
Country
Italy
I still don't quite understand how to download something from sockets. Do I basically do this?:

Code:
while(socket buffer length > 0){
  recieve from socket();
}

You should first receive the header and check for content-length then iterate until you receive the complete content.
 

erman1337

Well-Known Member
Member
Joined
Sep 27, 2015
Messages
1,211
Trophies
0
Location
Brussels
XP
983
Country
Belgium
Is this enough to retrieve data with http using sockets? I can't test it without a real device
Code:
function getDataFromHTTP(ip, port, method, path, host, step, success)
    client = Socket.connect(ip, port)

    Socket.send(client, method .. ' ' .. path .. " HTTP/1.1\r\n" ..
    "Host: " .. host .. "\r\n")

    buffer = Socket.receive(client, 32768)
    length = string.match(buffer, "Content-Length: %d+")

    while #buffer < length do
        buffer = buffer + Socket.receive(client, 32768)
        step(#buffer, length)
    end

    success(buffer)
end


I'll add HTTP status checks later
 
Last edited by erman1337,

MasterFeizz

Well-Known Member
Member
Joined
Oct 15, 2015
Messages
1,098
Trophies
1
Age
29
XP
3,710
Country
United States

Rinnegatamante

Well-Known Member
Member
Joined
Nov 24, 2014
Messages
3,162
Trophies
2
Age
29
Location
Bologna
Website
rinnegatamante.it
XP
4,857
Country
Italy
Is this enough to retrieve data with http using sockets? I can't test it without a real device
Code:
function getDataFromHTTP(ip, port, method, path, host, step, success)
    client = Socket.connect(ip, port)

    Socket.send(client, method .. ' ' .. path .. " HTTP/1.1\r\n" ..
    "Host: " .. host .. "\r\n")

    buffer = Socket.receive(client, 32768)
    length = string.match(buffer, "Content-Length: %d+")

    while #buffer < length do
        buffer = buffer + Socket.receive(client, 32768)
        step(#buffer, length)
    end

    success(buffer)
end


I'll add HTTP status checks later

Socket.receive gives you a string, not a table so # operator shouldn't be allowed.
Also, with the first receive you'll probably get also a part of your content so your while cycle probably will never end.
 

erman1337

Well-Known Member
Member
Joined
Sep 27, 2015
Messages
1,211
Trophies
0
Location
Brussels
XP
983
Country
Belgium
Socket.receive gives you a string, not a table so # operator shouldn't be allowed.
Also, with the first receive you'll probably get also a part of your content so your while cycle probably will never end.
Ah I forgot Content-Length doesn't count the headers :P
The documentation says that using the # operator gives you the count of bytes: http://www.lua.org/manual/5.1/manual.html#2.5.5
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • BigOnYa @ BigOnYa:
    I kept thinking jaws was gonna come up and attack
  • K3Nv2 @ K3Nv2:
    Jaws is on a diet
  • K3Nv2 @ K3Nv2:
    Damn power went out
  • BigOnYa @ BigOnYa:
    Ok xdqwerty, your little bro prob tripped On the cord and unplugged you
  • K3Nv2 @ K3Nv2:
    Ya I'm afraid of the dark hug me
  • BigOnYa @ BigOnYa:
    Grab and hold close your AncientBoi doll.
  • K3Nv2 @ K3Nv2:
    Damn didn't charge my external battery either
  • BigOnYa @ BigOnYa:
    Take the batteries out of your SuperStabber3000... Or is it gas powered?
  • K3Nv2 @ K3Nv2:
    I stole batteries from your black mamba
    +1
  • K3Nv2 @ K3Nv2:
    My frozen food better hold up for an hour I know that
  • BigOnYa @ BigOnYa:
    Or else gonna be a big lunch and dinner tomorrow.
  • BigOnYa @ BigOnYa:
    Did you pay your power bill? Or give all yo money to my wife, again.
  • K3Nv2 @ K3Nv2:
    Oh good the estimated time is the same exact time they just said
    +1
  • BigOnYa @ BigOnYa:
    Load up your pc and monitor, and head to a McDonalds dining room, they have free WiFi
  • K3Nv2 @ K3Nv2:
    Sir please watch your porn in the bathroom
    +2
  • BigOnYa @ BigOnYa:
    No sir we can not sell you anymore apple pies, after what you did with the last one.
  • K3Nv2 @ K3Nv2:
    We ran out
  • HiradeGirl @ HiradeGirl:
    for your life
    +1
  • K3Nv2 @ K3Nv2:
    My life has no value my fat ass is staying right here
  • K3Nv2 @ K3Nv2:
    Nearly 4 hours without power :(
  • Veho @ Veho:
    SO POWERLESS
  • K3Nv2 @ K3Nv2:
    Tell Kanye I need power
    K3Nv2 @ K3Nv2: Tell Kanye I need power