Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

malloc.h #17

Open
GoogleCodeExporter opened this issue Dec 5, 2015 · 9 comments
Open

malloc.h #17

GoogleCodeExporter opened this issue Dec 5, 2015 · 9 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. make on Mac
2.
3.

What is the expected output? What do you see instead?
distance.c:18:10: fatal error: 'malloc.h' file not found
#include <malloc.h>
         ^
1 error generated.
make: *** [distance] Error 1

What version of the product are you using? On what operating system?
OSX 10.9.4

Please provide any additional information below.
I fixed it by replacing malloc.h with stdlib.h

Original issue reported on code.google.com by freqyi...@gmail.com on 17 Jul 2014 at 5:44

@GoogleCodeExporter
Copy link
Author

malloc.h is non-standard linux-specific header.
malloc() function always exists in stdlib.h - it's guaranteed by standard.
So, stdlib.h is much better than malloc.h

Original comment by alex.y.t...@gmail.com on 2 Dec 2014 at 11:05

@GoogleCodeExporter
Copy link
Author

Dirty solution, but it works:
In OSx Lion, Mountain Lion, Maveriks, Yosemite, the lib malloc.h is in the 
directory /usr/include/malloc
So, do:

 cd /usr/include/malloc
 sudo cp malloc.h ..

and then go to your word2vec folder and compile with make.

Original comment by zuccongu...@gmail.com on 13 Jan 2015 at 1:38

@GoogleCodeExporter
Copy link
Author

Dirty solution did not work for me:

distance.c:18:10: fatal error: 'malloc.h' file not found
#include <malloc.h>
         ^
1 error generated.
make: *** [distance] Error 1
$cp /usr/include/malloc/malloc.h .
$make
gcc distance.c -o distance -lm -pthread -O3 -march=native -Wall -funroll-loops 
-Wno-unused-result
distance.c:18:10: error: 'malloc.h' file not found with <angled> include; use 
"quotes" instead
#include <malloc.h>
         ^~~~~~~~~~
         "malloc.h"
distance.c:46:19: warning: implicitly declaring library function 'malloc' with 
type 'void *(unsigned long)'
  vocab = (char *)malloc((long long)words * max_w * sizeof(char));
                  ^
distance.c:46:19: note: please include the header <stdlib.h> or explicitly 
provide a declaration for 'malloc'
distance.c:31:8: warning: unused variable 'ch' [-Wunused-variable]
  char ch;
       ^
2 warnings and 1 error generated.
make: *** [distance] Error 1

Original comment by alexande...@gmail.com on 30 Jan 2015 at 8:08

@GoogleCodeExporter
Copy link
Author

You have to change <malloc.h> to "malloc.h" in all of the c files. Then it will 
compiles on osx.

Original comment by erroneou...@gmail.com on 10 Feb 2015 at 7:00

@GoogleCodeExporter
Copy link
Author

"malloc.h" must be removed from anywhere as a non-standatd header.
"stdlib.h" must be used instead.

See here 
http://stackoverflow.com/questions/12973311/difference-between-stdlib-h-and-mall
oc-h

Original comment by alex.y.t...@gmail.com on 10 Feb 2015 at 8:55

@GoogleCodeExporter
Copy link
Author

Yup, replacing "malloc.h" with "stdlib.h" in three c files got it working on my 
MacBook.

Original comment by pbro...@deepmile.com on 8 Apr 2015 at 9:32

@GoogleCodeExporter
Copy link
Author

because "stdlib.h" already exist in files, just delete "malloc.h".
 it works on my mac

Original comment by hxy...@gmail.com on 22 Apr 2015 at 3:19

@GoogleCodeExporter
Copy link
Author

Hello,guys! I have the same problem. I could not find both of "malloc.h" and 
"stdlib.h" , how could I replace them or delete them? Did I forget to download 
something? I am trying to install htk. Please give me a suggestion. Thank you!!!

Original comment by lilanlan...@gmail.com on 4 May 2015 at 8:11

@GoogleCodeExporter
Copy link
Author

Hey, they should already be on your system. Just replace the references in
the downloaded code.

-- Peter

Original comment by pbro...@deepmile.com on 4 May 2015 at 8:15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant