Jump to content
  • Advertisement
Sign in to follow this  

More Linux Complier Errors

This topic is 4172 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

// in header file included in all sources
#ifdef linux
#include <ext/hash_map>
namespace stdext = __gnu_cxx;
#include <hash_map>

inline static keyType_t Hash(const std::string &path) { return stdext::hash_map<std::string,Entry>::hasher(path); }; // hash function

Code Blocks error /home/bernard/C++ Projects/glfwHello/PakFile.h:18: error: no matching function for call to ‘__gnu_cxx::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::hash(const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)’ /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/ext/hash_fun.h:71: note: candidates are: __gnu_cxx::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::hash() /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/ext/hash_fun.h:71: note: __gnu_cxx::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::hash(const __gnu_cxx::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >&)
// reads count objects into output iterator dest
template <typename Stream,typename OutputIterator>
void Read(Stream &s,OutputIterator &dest, boost::uint32_t count)
    typename OutputIterator::value_type temp;
    while (count--)
Code Blocks error /home/bernard/C++ Projects/glfwHello/PakFile.cpp:93: instantiated from here /home/bernard/C++ Projects/glfwHello/iolib.h:13: error: variable or field ‘temp’ declared void
Instantiated from this code:
std::back_insert_iterator <std::string> it=std::back_inserter(fname);
For MSVC8 I had that code written as
But I don't think Linux liked that. fname is an std::string and nameLen is an unsinged 32 bit integer representing the length of fname in number of chars. #3 On top of all of that it no longer likes the CML library which was compiling just fine before I added all of my sources and headers to my project.
template < typename Real, typename E, class A > void
get_frustum_corners(Real planes[6][4], vector<E,A> corners[8])

    corners[0] =

, planes[BOTTOM], planes[NEAR]); corners[1] = detail::intersect_planes(planes

, planes[BOTTOM], planes[NEAR]); corners[2] = detail::intersect_planes(planes

, planes[TOP], planes[NEAR]); corners[3] = detail::intersect_planes(planes

, planes[TOP], planes[NEAR]); corners[4] = detail::intersect_planes(planes

, planes[BOTTOM], planes[FAR]); corners[5] = detail::intersect_planes(planes

, planes[BOTTOM], planes[FAR]); corners[6] = detail::intersect_planes(planes

, planes[TOP], planes[FAR]); corners[7] = detail::intersect_planes(planes

, planes[TOP], planes[FAR]); }

Code Blocks error cml::get_frustum_corners(Real (*)[4], cml::vector<E, AT>*)’: /home/bernard/Development_Tools/Libs/cml_1_0b1/cml/mathlib/frustum.h:194: error: expected primary-expression before ‘]’ token /home/bernard/Development_Tools/Libs/cml_1_0b1/cml/mathlib/frustum.h:196: error: expected primary-expression before ‘]’ token /home/bernard/Development_Tools/Libs/cml_1_0b1/cml/mathlib/frustum.h:198: error: expected primary-expression before ‘]’ token /home/bernard/Development_Tools/Libs/cml_1_0b1/cml/mathlib/frustum.h:200: error: expected primary-expression before ‘]’ token

Share this post

Link to post
Share on other sites
I found a solution for those errors:

inline static keyType_t Hash(const std::string &path) { return stdext::hash<char*>()(path.c_str()); }; // hash function

Fixed the first one, although I don't know if MVSC8 will compile that.

I fixed #2 by making another template that lets me set the value type, but I am still clueless as to why std::string::iterator::value_type==void?

I fixed #3 (at least it looks like it's solved) by putting cml/cml.h first in my header file.

Now I'm having difficulties getting libpng an freetype 2 to cooperate.

Share this post

Link to post
Share on other sites
hash_map::hasher isn't a function, but the type of a function. You have to "call" it twice: "stdext::hash_map<std::string, Entry>::hasher()(path)".

However, the default hash functor isn't, by default, overloaded for std::string. You'll either have to provide your own overload:

namespace stdext {
struct hash<std::string>
operator()(const std::string & __str) const
{ return __stl_hash_string(__str.c_str()); }

or store C strings in the hash.

std::back_insert_iterator <std::string>::value_type being void is, surprisingly, supported by the standard. Both the value_type and difference_type members of an output iterator are specified to be void. (STD: 24.3.1/1) Hopefully that weirdness will be fixed in the next version of the standard.

Since there are only four errors and they're all spaced two lines apart for the CML bug, I'd guess that either NEAR or FAR is defined as a macro.

Share this post

Link to post
Share on other sites
Thanks, I think I'm going to replace the use of hash_map, none of my code that uses it will compile. Even this fails:

// loads objects not found in pool from SourceT source
template <typename T,typename SourceT,typename ParamT=const char *>
class Pool
typedef stdext::hash_map<ParamT,T> map_t;
Pool(SourceT source_) : source(source_) { };
// retrieves reference T object specified by the param parameters
void operator()(T &object,ParamT param)
map_t::iterator it=loadedMap.find(param);
if (it==loadedMap.end())
{ // not found then load and add it
else // return it
SourceT source; // input source object
map_t loadedMap; // map of loaded objects

Code Blocks error
error: expected ';' before 'it'

I wonder if there is a good boost libraries solution. I see that there is boost::hash but I still haven't figured out how to make it into a replacement for hash_map.

I know that google has a solution, and that I could install the SGI library, but I already have boost and I would like as little hassle as possible.

I have CML working already, I guess including one of my other headers before it messed with it.

Share this post

Link to post
Share on other sites
Note: I already fixed the issues above. I'm using tr1::unordered_map with boost::hash.

How is it that this works fine on windows using MSVC8 but on Kubuntu using Code::Blocks and gcc it causes a segmentation fault or fails to load the texture?

if (genMipmaps) // generate mipmaps
gluBuild2DMipmaps(GL_TEXTURE_2D, raw.NChannels(), raw.Width(),
raw.Height(), pxType, GL_UNSIGNED_BYTE, &(*raw.pixels.begin()));
else // upload texture as mipmap level 0

// UploadMipmapLvl(GLenum pxType_,unsigned short idx_,bmp::RawData &raw) calls this

When genMipmaps==true I get a segmentation fault, when it is false the textured quad doesn't have a texture.

raw.Height() returns the height of the bitmap in pixels
raw.Width() returns the width of the bitmap in pixels
raw.NChannels() returns the number of color channels (in this case 3 for the RGB test image, which is loaded from a png)
raw.pixels is a std::vector<unsigned char> of the pixels in the image

I need to get over my fear of Linux and stop posting these threads. All I needed to do was enable TEXTURE_2D before calling glGenTextures. I feel so silly.

[Edited by - T1Oracle on July 16, 2007 6:14:09 AM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!